wms/wms_usher.sh

151 lines
2.2 KiB
Bash
Raw Normal View History

2023-03-06 19:08:25 +01:00
#!/bin/sh
2024-02-22 04:31:42 +01:00
## move and resize windows ##
2024-02-26 05:32:24 +01:00
# wms_usher.sh by @root_informatica.
2023-03-07 14:01:29 +01:00
2024-02-22 04:31:42 +01:00
. $HOME/.config/wms/wms_var
2023-03-06 19:08:25 +01:00
2024-01-21 04:05:04 +01:00
FLAG=$1
2023-03-06 19:08:25 +01:00
usage() {
2023-07-24 08:08:48 +02:00
cat<<EOF
usage:
2024-02-27 20:02:12 +01:00
wms_usher.sh [ -c, -f, -n, -s, -e, -o, -r, -l, -d, -u, -w, -W, -h, -H ]
-c) centered
2024-02-22 04:31:42 +01:00
-f) fullsize
-n) half north
-s) half south
-e) half est
-o) half west
-r) move right
-l) move left
-d) move down
-u) move up
-w) resize width -
-W) resize width +
-h) resize height -
-H) resize height +
2023-07-24 08:08:48 +02:00
EOF
2023-03-06 19:08:25 +01:00
}
2024-02-22 04:31:42 +01:00
# half north value
north() {
x=0
y=0
w=$SW
h=$((SH / 2 - BW))
2023-03-09 05:41:12 +01:00
}
2024-02-22 04:31:42 +01:00
# half south value
south() {
x=0
y=$((SH / 2 + BW))
w=$SW
2024-02-27 20:02:12 +01:00
h=$((SH / 2 - BW))
2023-03-09 05:41:12 +01:00
}
2024-02-22 04:31:42 +01:00
# half est value
est() {
x=$((SW / 2 + BW))
y=0
2024-02-27 20:02:12 +01:00
w=$((SW / 2 - BW))
2024-02-22 04:31:42 +01:00
h=$SH
}
2023-03-09 05:41:12 +01:00
2024-02-22 04:31:42 +01:00
# half west value
west() {
x=0
y=0
w=$((SW / 2 - BW))
h=$SH
2023-03-09 05:41:12 +01:00
}
2024-02-27 20:02:12 +01:00
# centered function.
center() {
# windows width.
ww=$((SW * WP / 100))
# windows height.
wh=$((SH * WP / 100))
x=$(((SW - ww) / 2))
y=$(((SH - wh) / 2))
wtp $x $y $ww $wh $FW
}
# fulsize function
2024-02-22 04:31:42 +01:00
fullsize() {
# original size and position.
osp=$(atomx WM_FS $FW)
# fullsize width.
fs_width=$((RW - BW * 2))
# fullsize height.
fs_height=$((RH - BW * 2))
x=0
y=0
2024-02-09 04:11:54 +01:00
2024-02-22 04:31:42 +01:00
# if atom exist and it is in fullsize
if [ -n "$osp" ] & [ "$(wattr wh $FW)" = "$fs_width $fs_height" ]; then
# restore size and position.
wtp $osp $FW
# remove atom from window.
atomx -d WM_FS $FW
else # if it's not atom and it's not in fullsize
# create atom and save original size and position.
atomx WM_FS="$(wattr xywh $FW)" $FW
# fullsize it.
wtp $x $y $fs_width $fs_height $FW
fi
}
2024-02-09 04:11:54 +01:00
2024-02-22 04:31:42 +01:00
case $FLAG in
2024-02-27 20:02:12 +01:00
-c)
center
;;
2024-02-22 04:31:42 +01:00
-f)
fullsize
;;
-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
;;
-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