Handling right clicks on a macbook running Linux

I’ve finally settled down to a solution that I am happy with. I used to have the following options inside my Xorg.conf:
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
[...snip...]
Option "TapButton1" "1"
Option "TapButton2" "3"
Option "TapButton3" "2"
Option "VertTwoFingerScroll" "1"
Option "HorizTwoFingerScroll" "1"
[...snip...]

This works like this:
i) a single tap is a left click
ii) a two-finger tap is a right click
iii) a three-finger tap is a middle click
and you could scroll horizontally and vertically using two fingers on the touchpad, like Mac OS X.
The problem with this setup is that I used to have a lot of accidental double tappings while scrolling with two fingers horizontally or vertically. This of course produced unwanted right clicks.

I wanted a solution that I could get right click in somehow like Mac OS X does it, using ctrl+tap/ctrl+click. I found a solution that emulated ctrl+click as a right click but then many applications started misbehaving. Firefox for example uses ctrl+click on Linux to open a link on a new tab, when I used ctrl+click as a right click, Firefox stopped opening the links. So I went to plan B.

CMD key(apple key)-click as a right click.

To achieve that:
a) install xvkbd.
Debian: apt-get install xvkbd
Gentoo: emerge xvkbd
b) install xbindkeys.
Debian: apt-get install xbindkeys
Gentoo: emerge xbindkeys
c) create the default .xbindkeysrc file: xbindkeys –defaults > ~/.xbindkeysrc
d) edit it and put the following inside: "xvkbd -text '\m3'"
mod4 + b:1 (mouse)

e) edit xorg.conf and set this: Option "TapButton2" "0"
This effectively disables double tapping as a right click.
f) restart X
g) open a terminal and start xbindkeys from it: $ xbindkeys -n -v
Now press CMD key and tap the touchpad or click the touchpad button. You should be greeted with a fresh right click!

If all went well put xbindkeys in your DE’s autostart.

The following works flawlessly on XFCE/LXDE. CMD-click or CMD-tap opens XFCE’s menu or LXDE’s desktop menu.

On fluxbox though there is still a problem. It’s very common for fluxbox key config to look something like the following:
OnDesktop Mouse1 :hideMenus
OnDesktop Mouse2 :workspaceMenu
OnDesktop Mouse3 :rootMenu
OnDesktop Mouse4 :nextWorkspace
OnDesktop Mouse5 :prevWorkspace

So to open the RootMenu, which is the basic menu with the applications shortcuts for fluxbox, one needs to actually right click on the Desktop. That worked with TabButton2=3 but it does not work right now. To get around that problem I binded the key left to (1/!) which is normally the (±/§) key on Macs to the Menu key using xmodmap.
$ cat .xmodmap
keycode 94 = Menu

I never used that key anyway…

I’ve now got my precious right click back without accidental miss-clicks. yihaa!

References: FreeBSD on an Apple MacBook

7 Responses to “Handling right clicks on a macbook running Linux”

  1. June 12th, 2009 | 03:40
    Using WordPress WordPress 2.7.1

    […] post:  Handling right clicks on a macbook running Linux | Into.the.Void. Share and […]

  2. June 12th, 2009 | 06:00
    Using WordPress WordPress 2.2.2

    […] …Read More […]

  3. June 12th, 2009 | 15:07
    Using Mozilla Firefox Mozilla Firefox 3.0.10 on Linux Linux

    Υπαρχουν επισης επιλογες που καθοριζεις ποση πιεση θεωρειται tap, και ποση click.
    Οποτε μετα αντιστοιχα μπορεις να κανεις Option “ClickFinger1” “…” κλπ, και να καταληξεις με αμετρητα gestures/shortcuts. Βολικη επισης ειναι η επιλογη ποσα ms θελει για να καταλαβει tap.

    Σου δινω τα δικα μου:
    Option “FingerLow” “25”
    Option “FingerHigh” “30”
    Option “MaxTapTime” “180”
    Option “MaxTapMove” “220”

    Ρυθμισμενο ωστε να καταλαβαινει σχετικα ευκολα τα taps, γιατι τα χρησιμοποιω συνεχεια (σαν middle button).
    Δες και το syndaemon. Απενεργοποιει το touchpad οταν γραφεις για να μην το ακουμπας καταλαθος. 🙂

  4. June 13th, 2009 | 09:45
    Using Mozilla Firefox Mozilla Firefox 3.0.10 on Mac OS X Mac OS X 10

    Προφανώς και χρησιμοποιώ τα παραπάνω που λες…απλά το post δεν ήταν περί synaptic αλλά ειδικά για το “right click” σε macbook 🙂

    Thanks anyway

  5. June 18th, 2009 | 08:25
    Using WordPress WordPress 2.8

    […] site admin wrote an interesting post today onHandling right clicks on a <b>macbook</b> running Linux | Into.the.Void.Here’s a quick excerpt […]

  6. macias
    March 8th, 2012 | 19:57
    Using Mozilla Firefox Mozilla Firefox 10.0.2 on Linux Linux

    It looks so promising and yet it does not work for me 🙁 When I tested it in XFCE I got:

    Button press !
    e.xbutton.button=1
    e.xbutton.state=64
    “xvkbd -text ‘\m3′”
    m:0x40 + b:1 (mouse)
    got screen 0 for window 15d
    Start program with fork+exec call
    xvkbd: Mode_switch not available as a modifier
    xvkbd: although ISO_Level3_Shift is used instead, AltGr may not work correctly
    Button press !
    e.xbutton.button=3
    e.xbutton.state=320
    Button release !
    e.xbutton.button=3
    e.xbutton.state=1344
    Button release !
    e.xbutton.button=1
    e.xbutton.state=320

    When I tried to write explicitly Super_R (xbindkeys claims it recognizes such symbols) it treated is as code 0, and in result my LMB clicking was treated as RMB clicking.

    openSUSE 11.2 if that matters.

  7. January 1st, 2014 | 01:57
    Using Mozilla Firefox Mozilla Firefox 24.0 on Ubuntu Linux Ubuntu Linux

    Macias: I was having this problem as well. It seemed like the event was registering but it would not run the command. I prepend ‘sleep .05 &&’ to the command so it will wait for the initiating command (and possibly any other mouse event consumers) to complete.

    I already posted my solution on superuser:

    http://superuser.com/questions/217615/how-to-right-click-using-the-keyboard-from-ubuntu-on-a-mac/695472#695472

    Looks like a long time waiting… 🙂

Leave a reply