3

I have a Logitech Performance MX mouse I want to configure for Ubuntu 14.10 using xbindkeys. I managed to install xbindkeys and xautomation following this post, however, the buttons still don't work.

Here is my xbindkeysrc file:

# For the benefit of emacs users: -*- shell-script -*-
###########################
# xbindkeys configuration #
###########################
#
# Version: 1.8.6
#
# If you edit this file, do not forget to uncomment any lines
# that you change.
# The pound(#) symbol may be used anywhere for comments.
#
# To specify a key, you can use 'xbindkeys --key' or
# 'xbindkeys --multikey' and put one of the two lines in this file.
#
# The format of a command line is:
#    "command to start"
#       associated key
#
#
# A list of keys is in /usr/include/X11/keysym.h and in
# /usr/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier:
#   Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock),
#   Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#

# The release modifier is not a standard X modifier, but you can
# use it if you want to catch release events instead of press events

# By defaults, xbindkeys does not pay attention with the modifiers
# NumLock, CapsLock and ScrollLock.
# Uncomment the lines above if you want to pay attention to them.

#keystate_numlock = enable
#keystate_capslock = enable
#keystate_scrolllock= enable

# Examples of commands:

"xbindkeys_show" 
  control+shift + q

# set directly keycode (here control + f with my keyboard)
#"xterm"
#  c:41 + m:0x4

# specify a mouse button
#"xterm"
#  control + b:2

#"xterm -geom 50x20+20+20"
#   Shift+Mod2+alt + s
#
## set directly keycode (here control+alt+mod2 + f with my keyboard)
#"xterm"
#  alt + c:0x29 + m:4 + mod2
#
## Control+Shift+a  release event starts rxvt
#"rxvt"
#  release+control+shift + a
#
## Control + mouse button 2 release event starts rxvt
#"rxvt"
#  Control + b:2 + Release

"xte 'key Control_L'"
b:10 

##################################
# End of xbindkeys configuration #
##################################

Thanks.

5
  • Can you edit your question to include your .xbindkeysrc file?
    – Seth
    Dec 3, 2014 at 22:12
  • @Seth, I've included my .xbindkeysrc file. I understand that 'key Control_L' is left Ctrl. But pressing button 10 on the mouse and, say, the key 'Q' to quit an application doesn't work. I've also tried under key combinations. I'd like to set button 10 to Super + W (Expose). Thank you. Dec 4, 2014 at 1:50
  • Sorry for the late reply. Is this "xte 'key Control_L'" b:10 what doesn't work? What do you expect that to do?
    – Seth
    Dec 16, 2014 at 18:15
  • this tutorial helped me a lot blog.hanschen.org/2009/10/13/mouse-shortcuts-with-xbindkeys Jan 18, 2017 at 4:40
  • I can't believe mapping mouse buttons is still an issue in 2017. Don't muck around with xev xte nonsense Why not use Btnx: main daemon Config GUI Install it quick and easy per instructions here: awesomelinux.blogspot.com/2012/08/…
    – Andrew Ch
    Dec 28, 2017 at 0:01

5 Answers 5

3

I know this questions is a year old, but it still seems to be unanswered.

I think your problem is that you just trigger xte 'key Control_L', which will just "tap" your control key, meaning the keypress is only emulated for a very short amount of time and then the key is released. You need to issue a keydown event when you start pressing the mouse button and fire a keyup event when you release the mouse button. Your .xbindkeysrc should look like this:

"xte 'keydown Control_L'"
    b:10

"xte 'keyup Control_L'"
    b:10 + Release
2

I found that xte is flakey. My sequence for mapping the the thumb button of my logitech 518 to 'control W' to close tabs and windows never worked well with xte not sequencing properly. For example this failed:

"xte 'keydown Control_L' 'w' 'keyup Control_L'"
 b:8

as did this:

"xte 'keydown Control_L' 'w' 'keyup Control_L'"
 b:8 + release

I also noticed that xte was slow. I tried xvkbd and it works well.

of course you have to get xvkbd with this:

sudo apt-get install xvkbd

Put this in your .xbindkeysrc file in your home directory

"xvkbd  -text '\C\[w]'"
m:0x0 + b:8

and restart xbindkeys

pkill -f xbindkeys && xbindkeys
1

I have a Logitech M705 and just went through this.

Button 8 maps to the forward/backward button on the side:

###########################
# xbindkeys configuration #
###########################
# Workspace Left
 "xte 'keydown Control_L' 'keydown Alt_L' 'key Left' 'keyup Alt_L' 'keyup Control_L'"
  b:8
##################################
# End of xbindkeys configuration #
##################################
0

Must be because the key control by itself does not do much.

Try this:

xte 'keydown Super_L' 'keydown Right' 'keyup Super_L' 'keyup Right'

This is basically Super[windows key]+Right_Arrow that must take any open window to the right half part of your screen.

This is just an example, you can automate any keys combination.

0

I was having trouble mapping my mouse buttons too. None of the existing answers here got to the heart of the issue.

TL;DR: Add the + release association to the mapping (see last code snippet).

As an example, I wanted to show the window overview, which I was trying to do with this:

"/usr/bin/dbus-send --session --print-reply --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();'"
  b:8

I added some logging to confirm xbindkeys was picking up the presses, which it was:

"echo 'b:8 pressed' > /tmp/.xbindkeys.log 2>&1"
  b:8

So given the key presses were working I knew the issue wasn't with xbindkeys picking up the presses, but somewhere else. I tried with simulating key presses with xte, but this also didn't work. However I noticed that something odd was going on with the focus of windows on the screen when I did this.

"/usr/bin/xte 'keydown Super_L' 'key s' 'keyup Super_L' >> /tmp/.xbindkeys.log 2>&1"
  b:8

As a stab in the dark I added the + release association to the command, which resolved the issue:

"/usr/bin/xte 'keydown Super_L' 'key s' 'keyup Super_L' >> /tmp/.xbindkeys.log 2>&1"
  b:8 + release

Given key assignments can change, using xte isn't a robust solution, so I wanted to go back to the dbus-send command. So swapping out the commands and including the + release association, everything worked right:

"/usr/bin/dbus-send --session --print-reply --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();'"
  b:8 + release

In hindsight I found a reference to this solution in the Arch wiki. Can anyone can shed light on why + release is needed in the comments?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .