5

I am running Ubuntu 16.04 and have connected Logitech M705 mouse. This mouse has a total of 10 buttons, button 1 being left click, button 2 right click, button 10 "thumb button".

I have set up xbindkeys

# History Back & Forward
"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L' "
  b:6 + Release
"xte 'keydown Alt_L' 'key Right' 'keyup Alt_L' "
  b:7 + Release

# page down
"xte 'key Next' "
  b:8

# page up
"xte 'key Prior' "
  b:9

# powerclick
"xte 'keydown Control_L' 'mouseclick 1' 'keyup Control_L' "

This all works very well. What I call powerclick is used to open links in FF in new tab.

Now what I would like to achieve: when I click button 1 THEN button 10 THEN I select some text and I release both buttons, text should be copied into clipboard. So kind of a quickedit mode for any window, as soon as text is selected this way, it is copied.

# quickcopy
"xte 'keydown Control_L' 'key c' 'keyup Control_L' "
  b:10  + b:1 + Release

But this does not do the desired effect.

Is there a way to map such complex conditions? I can imagine this being of a great use, considering that the "thumb button" might work similarly to Ctrl key on keyboard, i.e. to modify standard click behavior.

Later Id like to make Paste function for button 10 (thumb button) + button 2 (Right button)

Thanks

3

Running xbindkeys -n -v in a terminal outputs:

1 keys in /home/whoever/.xbindkeysrc

min_keycode=8     max_keycode=255 (ie: know keycodes)
"xte 'keydown Control_L' 'key c' 'keyup Control_L' "
    Release + m:0x0 + b:1   (mouse)
starting loop...

As I think m:0x0 is a mouse state, seems like xbindkeys is interpreting b:10 + b:1 + Release as simply b:1 + Release.

I don't know if we are doing it wrong and there is a correct way of writing it, or if using a two-mouse-button combination is simply not possible in xbindkeys.

| improve this answer | |
5

It's not possible to do normally, but fortunately xbindkeys supports a scripting language called guile that allows you to do things like set states/variables which allows you to create buttons that act like modifier keys.

I made a thread about it: https://www.linuxquestions.org/questions/linux-desktop-74/%5Bxbindkeys%5D-advanced-mouse-binds-4175428297/

| improve this answer | |
1

Example

implementing b:3 + b:1, right click in combination with left click send CTRL+F5 in this example... this require xbindkeys to be built with guile support

Create this additional config file /home/user/.xbindkeysrc.scm with the following content.

Basically this will

  • intercept first watched key > then
  • watch for second key
    • case of key1 + key2 it send its command
    • otherwise it send command for first key
    • restart xbindkeys (to start over in a clean way)
;;   This configuration is guile based.
;;   http://www.gnu.org/software/guile/guile.html


;; Right Click
(define (first-binding)
    "First binding"                                  
    (xbindkey-function '("b:3") b3-second-binding)
)

(define (reset-first-binding)
    "reset first binding"
    (ungrab-all-keys)
    (remove-all-keys)
)

(define (b3-second-binding)
    "Button Extra Functions"
    (reset-first-binding)
  
    ;; First Key Down + Second Key = Action Ctrl+F5 And Release
    (xbindkey-function '("b:1")
        (lambda ()
            (reset-first-binding)
            (run-command "xte 'keydown Control_R' 'keydown F5' 'keyup F5' 'keyup Control_R'")
            (run-command "killall xbindkeys; xbindkeys")
        )
    )
  
    ;; First Key Up = Release
    (xbindkey-function '(release "b:3") 
        (lambda ()
            (reset-first-binding)
            (run-command "xte 'mouseclick 3'")
            (run-command "killall xbindkeys; xbindkeys")
        )
    )
)

(first-binding) 

Thanks to David Bobb

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.