[ltp] tpb: switching between gnome workspaces
Roland Knöpfli
linux-thinkpad@linux-thinkpad.org
Tue, 30 Aug 2005 19:44:20 +0200
i just wrote a small script that uses wmctrl to switch between the
workspaces. then i configured /etc/tpbrc to run "scriptname.sh R" or
"script.sh L" when pressing the special forward and backward key on my
keyboard.
for those that are interestet in it, i paste a copy here:
--start-script----------------------------------------
#!/bin/bash
#
#number of workspaces in use
temp_01=`wmctrl -d | tail -n 1`
number_of_ws=${temp_01:0:1}
#
#active workspace?
temp_01=`wmctrl -d | grep \*`
active_ws=${temp_01:0:1}
#
#do the switching...
if [ "$1" = "R" ]; then
if [ "$active_ws" -lt "$number_of_ws" ]; then
new_ws=$[$active_ws + 1]
wmctrl -s $new_ws
else wmctrl -s 0
fi
elif [ "$1" = "L" ]; then
if [ "$active_ws" -gt "0" ]; then
new_ws=$[$active_ws - 1]
wmctrl -s $new_ws
else wmctrl -s $number_of_ws
fi
else
echo "ERROR: you have use L or R as parameters"
fi
--end-script------------------------------------------
it works fine for me using:
- fedora core 4 (gnome 2.10.0)
- wmctrl 1.07 (rpm found at:
http://fun.poosan.net/sawa/files/wmctrl-1.07-1.fc4.i386.rpm)
- tpb 0.6.3-4
i'm not a shell-script guru, so the script might not be as 'clean' as
when a real guru would write it.
Noah Dain wrote:
> On 8/29/05, Roland Knöpfli <roland.knoepfli@gmx.ch> wrote:
>
>>hi,
>>
>>i played around with tpb on my a31p. in the config file at /etc/tpbrc i
>>can set an action for every special-key like the home button. for
>>example: if i press the home button /usr/bin/firefox will start.
>>
>>as my a31p has special forward and backward keys near the common arrow
>>keys, i wanted to give them a function too. my idea is this:
>>
>>if i press "ctrl-alt-arrowleft/right" (i'm using gnome 2.10) i can
>>switch between the four virtual workspaces. it would be nice to
>>configure the forward/backward button to do this instead of using a
>>combination of three buttons.
>>
>>my question: is there a command i can execute to do the workspace
>>switching? if not, is there a possibility to simulate the
>>"ctrl-alt-arrowleft"-keystroke by executing a command?
>>
>>sorry for my bad english, but i hope you understand what i want.
>>
>>thanks,
>>roland
>
>
> you need wmctrl
>
> http://sweb.cz/tripie/utils/wmctrl/
>