compose key in MATE reverting xmodmap during startup

Sin respostas
chaosmonk

I am a member!

I am a translator!

Desconectado
Joined: 07/07/2017

I use MATE, with i3 as the window manager. From my i3 config file I run this script when I log in.

----------------------------------------------------
#!/bin/bash
xmodmap ~/.Xmodmap
xcape -e '#66=Escape'
xcape -e '#65=space'
----------------------------------------------------

where ~/.Xmodmap contains this:

----------------------------------------------------
clear lock
clear mod1
clear mod2
clear mod3
clear mod4
clear mod5
keycode 65 = Super_R
keycode 66 = Hyper_L
keycode 254 = Escape
keycode 255 = space
keycode 108 = ISO_Level3_Shift
add mod1 = Alt_L Alt_R Meta_L
add mod2 = Num_Lock
add mod3 = Hyper_L
add mod4 = Super_L Super_R
add mod5 = Mode_switch ISO_Level3_Shift
----------------------------------------------------

This remaps several keys according to my preferences.

Recently, I used mate-control-center to define a compose key. Ever since I did so, the keys are correctly remapped upon logging in only about 80% of the time. The rest of the time, the keys do not appear to be remapped at all.

If, during one of the sessions where the keys were not remapped correctly, I run the script manually, everything will be correct except that when I hit space bar, two spaces are output instead of one. If instead I just run

$ xmodmap ~/.Xmodmap

and omit the xcape commands, everything is correct. I also find that, during a normal session, running just

$ xcape -e '#65=space'

also causes space bar to output two spaces. It seems that in the sessions where the keymappings appear not to work, the xcape commands have in fact been executed correctly. It's just not noticable because all they do is restore the original behavior of the keys when used on their own after xmodmap has altered their behavior when used as a modifier. The problem, then, is with the xmodmap command.

I find that if, during a normal session, I reset the compose key in MATE control center, I reach the same state as during the abnormal sessions: The custom keymappings are gone, and running xmodmap restores them while running the complete script results in the two spaces issue. It seems that setting the compose key undoes the xmodmap command.

My suspicion is that most of the time MATE sets the compose key before xmodmap is run, but sometimes xmodmap is run first and is reverted when the compose key is set.

If I am correct, then I see three possible solutions: (a) Find a terminal command for setting the compose key that does not depend on MATE, and make that the first line of the keymapping script, (b) find a way to ensure that MATE never starts i3 until after it has set the compose key, or (c) run the keymapping script from somewhere other than my i3 config file (I already tried adding it to Startup Applications in mate-control-center, and xmodmap gets reverted every time).

Does anyone know how to do acheive any of these things or have any other ideas?