iso-profiles/mabox-linux/desktop-overlay/etc/skel/.config/tint2/scripts/desktop

45 lines
830 B
Plaintext
Raw Permalink Normal View History

2021-12-10 23:52:16 +01:00
#!/bin/bash
function get_current_desktop {
DSK=($(wmctrl -d | grep \* | tr -s ' ' | cut -d' ' -f1,10))
CUR_DSK=${DSK[0]}
CUR_DSK_NAME=${DSK[1]}
}
function get_desktop_count {
MAX_DSK=$(wmctrl -d | wc -l)
}
function switch_desktop {
get_current_desktop
get_desktop_count
MAX_IDX=$((MAX_DSK-1))
NEW_DSK=$((CUR_DSK+1))
if [ "$NEW_DSK" -lt 0 ]; then
NEW_DSK=${MAX_IDX}
elif [ "$NEW_DSK" -gt "$MAX_IDX" ]; then
NEW_DSK=0
fi
wmctrl -s $NEW_DSK
}
case "$1" in
info)
get_current_desktop
echo "<small>$CUR_DSK_NAME</small>"
;;
number)
get_current_desktop
echo $CUR_DSK
;;
next)
switch_desktop 1
;;
prev)
switch_desktop -1
;;
*)
echo "WRONG INPUT"
;;
esac