34 lines
1,001 B
Bash
Executable file
34 lines
1,001 B
Bash
Executable file
#!/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
|