146 lines
2.2 KiB
Bash
Executable file
146 lines
2.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
## move and resize windows ##
|
|
|
|
. /tmp/wms_var
|
|
|
|
FLAG=$1
|
|
# focused window id.
|
|
FW=$(pfw)
|
|
# root window id.
|
|
RID=$(lsw -r)
|
|
# root window width.
|
|
RW=$(wattr w $RID)
|
|
# root window height.
|
|
RH=$(wattr h $RID)
|
|
# screen utilizable width.
|
|
SW=$((RW - 2 * BW - 2 * GAP))
|
|
# screen utilizable height.
|
|
SH=$((RH - 2 * BW - 2 * GAP))
|
|
|
|
usage() {
|
|
cat<<EOF
|
|
usage:
|
|
wms_moveresize.sh [ -n, -s, -e, -o, -r, -l, -d, -u, -w, -W, -h, -H ]
|
|
-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 +
|
|
EOF
|
|
}
|
|
|
|
# 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))
|
|
w=$SW
|
|
h=$((SH / 2))
|
|
}
|
|
|
|
# half est value
|
|
est() {
|
|
x=$((SW / 2 + GAP + BW))
|
|
y=$GAP
|
|
w=$((SW / 2))
|
|
h=$SH
|
|
}
|
|
|
|
# half west value
|
|
west() {
|
|
x=$GAP
|
|
y=$GAP
|
|
w=$((SW / 2 - BW - GAP))
|
|
h=$SH
|
|
}
|
|
|
|
# fulsize function
|
|
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
|
|
|
|
# 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
|
|
}
|
|
|
|
case $FLAG in
|
|
-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
|