Cycle through your workspaces in a loop on Ubuntu 2010-06-05
Related Links:
Comments
Display comments as
(Linear | Threaded)
Add Comment
yet another geek
#!/bin/sh
num=$(wmctrl -d | wc -l)
wmctrl -s $(wmctrl -d | awk '/[0-9]+ +\*/ {print ($1+1)%'$num' }')
Well, this works. But I thought: "What about cycling in both directions?"#!/bin/sh
function usage {
echo "Usage: $0 {--left|--right}"
exit
}
if [ -n "$1" ]; then
case $1 in
--left) DIR=-1;;
--right) DIR=1;;
*) usage
esac
MAX=$(wmctrl -d | wc -l)
CMD='/\*/{ rv=($1+'$DIR')%'$MAX'; } END { print (rv < 0) ? ('$MAX'-1) : rv; }'
NEW=$(wmctrl -d | awk "$CMD")
wmctrl -s $NEW
else
usage
fi
You could pimp it by showing your current desktop number.# add before "wmctrl -s $NEW"
MSG=$(($NEW+1))
# nice but TOO SLOW!!!
# notify-send "Desktop $MSG" -i gnome-terminal
# better:
FONT="-adobe-helvetica-bold-r-*-*-200-*-*-*-*-*-*-*"
OPT="--outline 4 --outlinecolour black --pos middle --align center -l 1"
killall -q osd_cat
echo "< $MSG >" | osd_cat --delay=1 $OPT --font=$FONT - &
For the first scipt you only need wmctrl. Open a terminal by pressing Ctrl+Alt+t and type (or copy) the command beginning after "~$ " and press Enter:
you@terminal:~$ sudo apt-get install wmctrl
For the second you will also need xosd:
you@terminal:~$ sudo apt-get install xosd-bin
If you saved the script in ~/myWspSwitch.sh you can use it like this:
you@terminal:~$ ./myWspSwitch.sh --right
you@terminal:~$ ./myWspSwitch.sh --left
Or better, bind these commands to some keys, like <Super>Tab for right and <Shift><Super>Tab for left.you@terminal:~$ gconf-editor
You will see a file-explorer-like window. Browse to /apps/metacity/global_keybindings/ and select the first unused run_command.© 2010 yet-another-geek.org | Imprint | RSS 2.0 feed | ATOM 1.0 feed | Back to top
Design by Andreas Viklund | Serendipity Template by Carl | custom mod by yet-another-geek.org