diff options
-rwxr-xr-x | wpos.sh | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -15,19 +15,28 @@ if [ -n "$2" ]; then PROFILE="$2" fi +query() { + wmctrl -lxG +} + +parse() { + LINE="$1" + ID="$(echo "$LINE" | awk '{ print $1 }')" + GRAVITY="$(echo "$LINE" | awk '{ print $2 }')" + POSX="$(echo "$LINE" | awk '{ print $3 }')" + POSY="$(echo "$LINE" | awk '{ print $4 }')" + WIDTH="$(echo "$LINE" | awk '{ print $5 }')" + HEIGHT="$(echo "$LINE" | awk '{ print $6 }')" +} + if [ "$1" = "save" ]; then - wmctrl -lxG > "$SAVEPATH/$PROFILE" + query > "$SAVEPATH/$PROFILE" exit 0 elif [ "$1" = "restore" ]; then cat "$SAVEPATH/$PROFILE" | while read LINE; do ## Parse records in savefile - ID="$(echo "$LINE" | awk '{ print $1 }')" - GRAVITY="$(echo "$LINE" | awk '{ print $2 }')" - POSX="$(echo "$LINE" | awk '{ print $3 }')" - POSY="$(echo "$LINE" | awk '{ print $4 }')" - WIDTH="$(echo "$LINE" | awk '{ print $5 }')" - HEIGHT="$(echo "$LINE" | awk '{ print $6 }')" + parse "$LINE" ## Check few important values [ "$GRAVITY" -lt 0 ] && continue |