38 lines
1.1 KiB
Bash
Executable file
38 lines
1.1 KiB
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.
|
|
|
|
# if we're feeling spartan, just print a simple string for the executor
|
|
if [ -z $1 ]; then
|
|
echo ""
|
|
|
|
# if we pass '-x', spit a few hexadecimal bytes into the executor for eye-candy
|
|
elif [ "$1" = "-x" ]; then
|
|
od -vAn -N2 -x < /dev/urandom
|
|
|
|
# otherwise switch desks
|
|
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
|