[Solved] Assigning mouse keys depending on what application is running

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
ZFR
Level 1
Level 1
Posts: 36
Joined: Sat Jan 11, 2020 8:23 am

[Solved] Assigning mouse keys depending on what application is running

Post by ZFR »

I'm trying to emulate Logitech's software for my G400s mouse. I've managed managed to change DPI and polling rates, and the thing left now is to assign my remaining mouse buttons, and have them bound to keys/scripts depending on what application is running. So for example:

Default:
key 5 bind to Enter
key 6 bind to Escape
key 10 launch Calculator

Old_Game_1:
key 5 bind to Up Arrow
key 6 bind to Down Arrow
key 10 bind to Space

I used xev to find out the button numbers, then used xbidnkeys to assign those keys to scripts and xvkbd to simulate keyboard presses. This worked. However I don't know how to change those bindings depending on what program is running.

So:
a) Is xbindkeys and xvkbd the best way to do it? and
b) Is it possible to change those bindings depending on what program is running?
Last edited by ZFR on Mon Jan 13, 2020 11:06 pm, edited 1 time in total.

ZFR
Level 1
Level 1
Posts: 36
Joined: Sat Jan 11, 2020 8:23 am

Re: Assigning mouse keys depending on what application is running

Post by ZFR »

Fixed it!

Using imwheel
https://wiki.archlinux.org/index.php/IMWheel

Problem was, it stopped the navigation Back/Forward buttons from working properly.
https://askubuntu.com/questions/421645/ ... m-my-mouse
The solution offered there was to restrict it so it only affect the scrollwheel. But that defeated the purpose of using it for what I wanted it to do.

I made it work, by binding the thumb buttons to Left_Alt+Arrow keys, which is used for back/forward navigation for default all programs.
So my .imwheelrc file was

Code: Select all

"^game_name$"
, Thumb1, Escape
, Thumb2, R

".*"
, Thumb1, Alt_L|Left
, Thumb2, Alt_L|Right
which binds the keys Escape and R to the two thumb buttons when game_name is running. And uses Alt+Left/Right for other applications.

It can even do simple keyboard macros. And this, combined with the Shortcuts in Keyboard Settings can be used to run more complex scripts.

Took me a day, but I finally managed to completely emulate what Logitech's Software did for my mouse in Windows. DPI changes, key bindings, macro bindings and separate profiles for games.

Konaan
Level 1
Level 1
Posts: 29
Joined: Mon Jan 13, 2020 5:35 pm

Re: [Solved] Assigning mouse keys depending on what application is running

Post by Konaan »

If I remember correctly, I think Logitech support is coming to one of the newer kernels, if not out already. Was excited to see that. May eliminate the need to round about fixes.

Post Reply

Return to “Newbie Questions”