summaryrefslogtreecommitdiffstats
path: root/wpos.sh
diff options
context:
space:
mode:
Diffstat (limited to 'wpos.sh')
-rwxr-xr-xwpos.sh23
1 files changed, 16 insertions, 7 deletions
diff --git a/wpos.sh b/wpos.sh
index 2695f15..1fecd4d 100755
--- a/wpos.sh
+++ b/wpos.sh
@@ -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