desks.sh (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/bin/sh # this is a simple script to both give some semblance of eye-candy for a tint2 executor # and to switch virtual desktops programmatically, to be invoked by button click/scroll # on said executor. # copyleft 2020 Derek Stevens <drkste@zoho.com> # MIT License - do whatever you want if [ -z $1 ]; then od -vAn -N2 -x < /dev/urandom else currentDeskNum=$(wmctrl -d | grep -n [*] | awk '{print $1}' | awk -F : '{print $1}') numDesks=$(wmctrl -d | wc -l) case $1 in "-n") if [ ${currentDeskNum} -eq ${numDesks} ]; then newDesk=$(wmctrl -d | head -n 1 | awk '{print $1}') else newDesk=$(wmctrl -d | head -n $((currentDeskNum + 1)) | tail -n 1 | awk '{print $1}') fi ;; "-p") if [ ${currentDeskNum} -eq 1 ]; then newDesk=$(wmctrl -d | tail -n 1 | awk '{print $1}') else newDesk=$(wmctrl -d | head -n $((currentDeskNum - 1)) | tail -n 1 | awk '{print $1}') fi ;; esac wmctrl -s ${newDesk} fi |