Show desktop mapped to mousebutton in compiz

I love my 5 button mouse like no man should love an inanimate object. It’s getting on a bit and starting to go a little yellow, but that’s not the point. When I used this mouse on a Mac I could map the side buttons to Exposé actions, like tile all windows and show the desktop. I want to do the same in Linux, damnit.

With compiz you can do lots of lovely (and some pointless) things. Things like making the windows wobbly, or make it rain flaming globs of semen. I think. What you can’t do is map a mouse button to the show desktop action. Poop.

I searched for a while and came across this page with a very handy little script. A quick correction/update to the syntax and it works a treat.

From the command line

sudo apt-get install wmctrl
gedit ~/showdesktop.sh

paste this in :

#!/bin/bash desktopStatus=`wmctrl -m | grep mode | cut -d\: -f2`
if [ "$desktopStatus" = " OFF" ]
then
wmctrl -k on
else
wmctrl -k off
fi

Save and go back to command line

chmod +x ~/showdesktop.sh

You can now specify this command to run from a mouse button. Button 9 in my case. Open up compizconfig, go into commands and enter ~/showdesktop.sh in one of the commands then bind your button in the button bindings tab.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.