-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsnap
executable file
·37 lines (33 loc) · 897 Bytes
/
snap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# $ wmctrl -d
# 0 * DG: 1920x1200 VP: 0,0 WA: 0,31 1920x1169 Workspace 1
# 1 - DG: 1920x1200 VP: N/A WA: 0,31 1920x1169 Workspace 2
xorigin=0
yorigin=0
width=640
height=480
while read desktop current dg resolution vp vporigin wa waorigin waresolution name; do
if test "$current" = "*"; then
IFS='x' read width height <<<"$waresolution"
IFS=',' read xorigin yorigin <<<"$waorigin"
break
fi
done <<<"$(wmctrl -d)"
echo "workarea is @${width}x${height}+$xorigin+$yorigin"
half=$((width/2))
margin=8 # allow for window borders
case $1 in
left)
coords=0,$xorigin,$yorigin,$((half-margin)),-1
;;
right)
coords=0,$((xorigin+half)),$yorigin,$((half-margin)),-1
;;
*)
echo "Usage: snap {left|right}" 1>&2
exit 1
;;
esac
wmctrl -r :ACTIVE: -b remove,maximized_horz
wmctrl -r :ACTIVE: -b add,maximized_vert
wmctrl -r :ACTIVE: -e $coords