Workspace Switching Mouse button 6 & 7 without compiz

Share here your personal tips or creations: desktop, conky, docks, widgets or tweaks are welcomed here!
User avatar
gazza
Posts: 71
Joined: 27 Oct 2013 00:11
Location: Australia

Workspace Switching Mouse button 6 & 7 without compiz

Postby gazza » 28 Oct 2013 01:01

First off a huge thank you to GeneC for sharing his tweaks, I found some of them very useful as I'm a first time xfce user.

I have this obsession, I always get 7 button mice where button 6 & 7 are activated by tilting the scroll wheel left or right. I usually run compiz and hook these buttons to the workplace switcher, so all I need do it tilt my scroll wheel and I switch workspaces. It's the only reason I install compiz.

But since this is a fesh install of a new OS, I thought I'd try and do it without the huge overhead. This is what I did.

Install wmctrl and xbindkeys

Code: Select all

sudo apt-get install xbindkeys
sudo apt-get install wmctrl
edited a script I found on the web to switch workspaces back and forward between workspaces (it only went forward). Here is my edited script. I called it xfce-workspace-switcher.sh

Code: Select all

#!/bin/bash
total=$(wmctrl -d | wc -l)
current=$(wmctrl -d | sed -n 's/^\([0-9]\+\) *\*.*/\1/p')
if [ -z "$total" ] || [ -z "$current" ]; then
    echo 1>&2 "$0: Could not obtain workspace information!"
    exit 2
fi
if [ "$1" = "+" ];then
    target=$(($current+1))
    if [ $target = $total ]; then
	target=0
    fi
    wmctrl -s $target
elif [ "$1" = "-" ]; then
    target=$(($current-1))
    if [ $target -lt 0 ]; then
	target=$(($total-1))
    fi
    wmctrl -s $target
else
    echo "need - or + as a paramater to switch workspaces"
fi
placed in my ~/bin/Scripts directory , made it exicutable obviously.

Then I made the xbindkeys default config

Code: Select all

xbindkeys --defaults > $HOME/.xbindkeysrc
made the following edits in it

Code: Select all

"/home/gazzax/bin/Scripts/xfce-workspace-switcher.sh -"
  b:8
"/home/gazzax/bin/Scripts/xfce-workspace-switcher.sh +"
  b:9
Note, I'm using button 8 & 9 as my current mouse uses them, some mice I've had use 6 & 7 , use xev to determine what your extra buttons are.
Also note the '-' and the '+' are the paramaters sent to the script, they tell it which direction you want to go.

then all I did was type

Code: Select all

xbindkeys
in the terminal and now I can switch workspaces with a click of the mouse :D I'll be adding xbindkeys to my startup applications.

Resourses
Note the askubuntu is KDE orientated so if your on kde it would be nice to get feedback if the dbus command works.
http://askubuntu.com/questions/5229/how ... workspaces
http://blog.hanschen.org/2009/10/13/mou ... xbindkeys/

Hope this helps someone :D
Don't miss the donut by looking through the hole.

Return to “Customizations”

Who is online

Users browsing this forum: No registered users and 1 guest