Using the Mouse to Switch Workspaces in Linux Mint

Republished from February 28, 2015 @ 2:18 pm

I’m using Linux Mint 17.1 Rebecca with Cinnamon and like to use multiple workspaces. Some Linux desktops allow you to assign a mouse button to switch between workspaces but Cinnamon won’t let me assign high order mouse buttons (greater than Button 7). I’m using an old Logitech MX Revolution mouse that has a thumb wheel which I prefer to use to switch workspaces.

Below are the button assignments for the MX Revolution

Button # Description
1 Left mouse button
2 Left and right mouse buttons together
3 Right mouse button
4 Mouse wheel up
5 Mouse wheel down
6 Mouse wheel tilt left
7 Mouse wheel tilt right
8 Back button
9 Forward button
10 — none —
11 — none —
12 — none —
13 Thumb wheel push (forward, away)
14 — none —
15 Thumb wheel pull (back, toward user)
16 — none —
17 Thumb wheel click (down, in)

I used this page as a basis, I came up with the following solution.

I started by installing xbindkeys and xautomation.

$ sudo apt-get install xbindkeys xautomation

xbindkeys allows you to specify an action to be taken when a key or key combination is pressed or when a mouse button is clicked. xautomation includes a program xte that will send a fake keystroke to Xwindows.

I created a .bindkeysrc file in my home folder with the following command:

$ xbindkeys --defaults > $HOME/.xbindkeysrc

This will setup a default .xbindkeysrc file with some helpful examples and instructions. Notice that # at the beginning of a line indicates a comment.

The format of a line in the .xbindkeysrc file is:

"command to start"
associated key

Notice that the command to start is in double quotes. The is the command that will be executed when associated key is encountered. The associated key line is indented one space (I don’t know if it is any white space or a single space).

I added two entries:

# Workspace Left
"xte 'keydown Control_L' 'keydown Alt_L' 'key Left' 'keyup Alt_L' 'keyup Control_L'"

# Workspace Right
"xte 'keydown Control_L' 'keydown Alt_L' 'key Right' 'keyup Alt_L' 'keyup Control_L'"

What the first entry says is when Button 13 is pressed (b:13), execute xte and tell it to send CTRL-ALT-Left. The second entry says when Button 15 is pressed (b:15), exeute xte and tell it to send CTRL-ALT-Right.

Now stop xbindkeys and restart it.

$ killall xbindkeys
$ xbindkeys


Using the Mouse to Switch Workspaces in Linux Mint
Tagged on: