summaryrefslogtreecommitdiffstats
path: root/wpos.sh
diff options
context:
space:
mode:
authorGravatar Robin Obůrka <r.oburka@gmail.com> 2015-03-21 13:20:35 +0100
committerGravatar Robin Obůrka <r.oburka@gmail.com> 2015-03-21 13:20:35 +0100
commit1cc1d0f8a186819338d3ba16b2c198808d9e6032 (patch)
tree00ad17a8dbc39c9ce07b94f247589a9b41ebd59a /wpos.sh
parentAdd "none" command (diff)
downloaddisplay_autoset-1cc1d0f8a186819338d3ba16b2c198808d9e6032.tar.xz
Provide first simple version of wpos - windows restorer
Diffstat (limited to 'wpos.sh')
-rwxr-xr-xwpos.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/wpos.sh b/wpos.sh
new file mode 100755
index 0000000..7770358
--- /dev/null
+++ b/wpos.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+DEFAULT_PROFILE="auto"
+SAVEPATH="/tmp/wpos"
+mkdir -p "$SAVEPATH"
+
+if [ "$1" = "save" ]; then
+ wmctrl -lxG > "$SAVEPATH/$DEFAULT_PROFILE"
+ exit 0
+
+elif [ "$1" = "restore" ]; then
+ cat "$SAVEPATH/$DEFAULT_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 }')"
+
+ ## Check few important values
+ [ "$GRAVITY" -lt 0 ] && continue
+ [ "$(($POSY - 40 ))" -ge 0 ] && POSY=$(($POSY - 40))
+
+ ## And run command
+ wmctrl -i -r "$ID" -e "$GRAVITY","$POSX","$POSY","$WIDTH","$HEIGHT"
+ done
+
+fi