wms/wms_moveresize.sh

136 lines
2.3 KiB
Bash
Raw Normal View History

2023-03-06 19:08:25 +01:00
#!/bin/sh
2023-03-07 14:01:29 +01:00
## move and resize windows ##
2023-08-08 04:42:24 +02:00
. /tmp/wms_var
2023-03-13 04:42:50 +01:00
FLAG=$1 # flag
FW=$(pfw) # focused window id
RID=$(lsw -r) # root window id
RW=$(wattr w $RID) # root window width
RH=$(wattr h $RID) # root window heigth
SW=$((RW - 2 * BW - 2 * GAP)) # screen utilizable width
SH=$((RH - 2 * BW - 2 * GAP)) # screen utilizable height
2023-03-06 19:08:25 +01:00
usage() {
2023-07-24 08:08:48 +02:00
cat<<EOF
usage:
2023-03-20 02:46:41 +01:00
wms_moveresize.sh [ -n, -s, -e, -o, -r, -l, -d, -u, -w, -W, -h, -H ]
2023-03-13 04:42:50 +01:00
-f) fullsize
-n) half north
-s) half south
-e) half est
-o) half west
2023-03-06 19:08:25 +01:00
-r) move right
-l) move left
-d) move down
-u) move up
-w) resize width -
-W) resize width +
-h) resize height -
2023-07-24 08:08:48 +02:00
-H) resize height +
EOF
2023-03-06 19:08:25 +01:00
}
2023-03-13 04:42:50 +01:00
# half north value
north() {
x=$GAP
y=$GAP
w=$SW
h=$((SH / 2 - GAP - BW))
}
# half south value
south() {
x=$GAP
y=$((SH / 2 + GAP + BW))
2023-03-13 04:42:50 +01:00
w=$SW
h=$((SH / 2))
2023-03-13 04:42:50 +01:00
}
# half est value
est() {
x=$((SW / 2 + GAP + BW))
2023-03-13 04:42:50 +01:00
y=$GAP
w=$((SW / 2))
2023-03-13 04:42:50 +01:00
h=$SH
}
# half west value
west() {
x=$GAP
y=$GAP
w=$((SW / 2 - BW - GAP))
h=$SH
}
# fulsize function
fullsize() {
fs=$(atomx WM_FS $FW) # atom fullsize and original size position
fs_width=$((RW - BW * 2)) # fullsize width
fs_height=$((RH - BW * 2)) # fullsize height
x=0
y=0
# if atom exist and it is in fullsize
if [ -n "$fs" ] & [ "$(wattr wh $FW)" = "$fs_width $fs_height" ]; then
wtp $fs $FW # restore size and position
2023-10-11 20:06:17 +02:00
atomx -d WM_FS $FW # remove atom from window
2023-03-13 04:42:50 +01:00
else # if it's not atom and it's not in fullsize
2023-03-31 03:21:59 +02:00
atomx WM_FS="$(wattr xywh $FW)" $FW # create atom and save original size an position
2023-10-11 20:06:17 +02:00
wtp $x $y $fs_width $fs_height $FW # fullsize
2023-03-13 04:42:50 +01:00
fi
}
2023-03-06 19:08:25 +01:00
case $FLAG in
2023-03-13 04:42:50 +01:00
-f)
fullsize
wtp $x $y $w $h $FW
;;
-n)
north
wtp $x $y $w $h $FW
;;
-s)
south
wtp $x $y $w $h $FW
;;
-e)
est
wtp $x $y $w $h $FW
;;
-o)
west
wtp $x $y $w $h $FW
;;
2023-03-06 19:08:25 +01:00
-r) # rigth
wmv 10 0 $FW
;;
-l) # left
wmv -10 0 $FW
;;
-d) # down
wmv 0 10 $FW
;;
-u) # up
wmv 0 -10 $FW
;;
-w) # width -
wrs -10 0 $FW
;;
-W) # width +
wrs 10 0 $FW
;;
-h) # higth -
wrs 0 -10 $FW
;;
-H) # hight +
wrs 0 10 $FW
;;
*)
usage
;;
esac