So, I'm using Elementary OS for a long time and one day I decided to install Gnome DE for variety. I started to customizing it for myself and everything was ok, until I got to xbindkeys. I'm using this program in my Pantheon DE (default DE for Elementary OS) for mapping mouse arrows as desktop switchers - it's very comfortable.

So in Gnome (Xorg) it works at half. In US keyboard layout everything is good, it works very well. But when I switch to the russian keyboard layout it just stops working. Daemon is still working, but nothing happened. I decided to run xbindkeys -v to get more information. I realized that e.xbutton.button is the same at all layouts, but e.xbutton.state is strange on russian layout - 8208. I found this post, get the patch from it, get xbindkeys source by typing: git clone http://git.savannah.gnu.org/cgit/xbindkeys.git. Git didn't want to apply patch by git apply -v xbindkeys_patch.patch, it says, what can't find wanted line. I opened file, which should be edited, and realized, that it already has this fixed. Very interesting! I builded it and installed it as sayng in the 'INSTALL' file:

$ ./configure
$ make
$ sudo make install

Now the following happened: xbindkeys now received mouse button in russian layout and switch desktop, but... But it takes a second or 1.5 seconds. On US layout everything works immediately like before.

I decided to dig deeper. Using the best debuging principles (prinf-debuging) I found a problem in source code. This program uses Xlib API and it calls to XNextEvent() function, which takes this extremely lot of time on russian layout.

So it happens only in Gnome session. And I don't know what to do next. I would appreciate any help.

  • If this issue is Gnome-specific, would you like to report it to the Gnome developers, so they could fix it? Or (if you believe it to be elementary OS-specific) to elementary OS devs? – a-tokarev Aug 1 '19 at 11:37
  • Yeah, soon I'll try this program on another distro with Gnome and understand is it Elemetary Os-specific or Gnome-specific. But I already found this: state of pressed button in Xlib API means modifier-buttons pressed with that key. So, I can conclude, that Gnome-session switch languages in another way than Pantheon. Also I found that the language, which is highest in preferences, is the most workable for xbindkeys (and other programs like this). So, if I russian language is higher than english, it works immediately on russian layout, but with timeout on english. – Daniil Polyakov Aug 2 '19 at 7:23
  • Really interesting finding! – a-tokarev Aug 2 '19 at 7:39
  • Ok, I tryed xbindkeys in Ubuntu 18.04 live, and it works the same. I started thinking, that it's a Gnome problem. But then I got a XNextEvent example and modified it to print button state, and it works immediately on every layout. So, the problem is in the xbindkeys, that slow down the XNextEvent() function on another layout in Gnome. I don't know how did author do that. Some preference setted it program slow it down. Now I need Xlib-programer advice, omg. – Daniil Polyakov Aug 4 '19 at 13:46

Ok, I've found a way to fix this. I created simple script in python, that changes layouts order in preferences when the layout changing event was received. And it works!

My sript: https://github.com/Arjentix/Gnome-Layout-Fix

Hope it will be useful for someone, who will have the same problem.

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.