wms/wms_value.sh
2023-09-26 01:25:05 -03:00

128 lines
2.4 KiB
Bash
Executable file

#!/bin/sh
# check if there is variable file in /tmp for source. if it's not there, copy it
if [ -f /tmp/wms_var ]; then
. /tmp/wms_var
else
cp $HOME/.config/wms/wms_var /tmp/wms_var
. /tmp/wms_var
fi
FLAG=$1 # input
RID=$(lsw -r) # root window id
FW=$(pfw) # focused window
WMSVAR="/tmp/wms_var" # variable temporary file
usage() {
cat<<EOF
usage:
wms_revalue.sh [ -b, -B, -d, -g, -G, -m, -M, -w, -W]
-b) minimize borderwidth
-B) maximize borderwidth
-d) load default
-g) minimize gaps
-G) maximize
-m) minimize tiling master area
-M) maximize tiling master area
-w) minimize window percentage
-W) maximize window percentage
EOF
}
border_inc() {
if [ $BW -le 10 ]; then
sed -i "s/^.*\bBW=\b.*$/BW=$((BW + 2))/" $WMSVAR
wms_mainrole.sh $FW
fi
} # +2 pixel calculation
border_dec() {
if [ $BW -ge 4 ]; then
sed -i "s/^.*\bBW=\b.*$/BW=$((BW - 2))/" $WMSVAR
wms_mainrole.sh $FW
fi
} # -2 pixel calculation
gap_inc() {
if [ $GAP -le 40 ]; then
sed -i "s/^.*\bGAP=\b.*$/GAP=$((GAP + 2))/" $WMSVAR
wms_usher.sh -t
fi
}
gap_dec() {
if [ $GAP -ge 2 ]; then
sed -i "s/^.*\bGAP=\b.*$/GAP=$((GAP - 2))/" $WMSVAR
wms_usher.sh -t
fi
}
master_inc() {
if [ $MP -le 80 ]; then
sed -i "s/^.*\bMP=\b.*$/MP=$((MP + 5))/" $WMSVAR
wms_usher.sh -t
fi
} # 5% + calculation
master_dec() {
if [ $MP -ge 20 ]; then
sed -i "s/^.*\bMP=\b.*$/MP=$((MP - 5))/" $WMSVAR
wms_usher.sh -t
fi
} # 5% - calculation
windowperc_inc() {
if [ $WP -le 90 ]; then
sed -i "s/^.*\bWP=\b.*$/WP=$((WP + 5))/" $WMSVAR
wms_usher.sh -w
fi
} # 5% + calculation
windowperc_dec() {
if [ $WP -ge 60 ]; then
sed -i "s/^.*\bWP=\b.*$/WP=$((WP - 5))/" $WMSVAR
wms_usher.sh -w
fi
} # 5% - calculation
if [ -n "$FLAG" ]; then
case $FLAG in
-b) # decrease border width
border_dec
;;
-B) # increase border width
border_inc
;;
-d) # load defaults
cp $HOME/.config/wms/wms_var /tmp/wms_var
;;
-g) # decrease gaps
gap_dec
;;
-G) # increase gaps
gap_inc
;;
-m) # reduce tiling master area
master_dec
;;
-M) # increase tiling master area
master_inc
;;
-w) # reduce window size
windowperc_dec
;;
-W) # increase window size
windowperc_inc
;;
*)
usage
;;
esac
else
exit 0
fi