I wrote a `.Xmodmap` file and use `xmodmap .Xmodmap` to read it. It contains the following:
keycode 61 = minus underscore endash emdash
But testing it with xev shows that using the Alt/Option key together with the minus key generates no symbol. When I press the Alt/Option key, I get a key press and release events for `ISO__Level3_Shift`. I was expecting it to work as a Mode_switch! Strangely enough, my “Apple Laptop” keyboard model with the “Switzerland German (Macintosh)” layout seem to work fine, otherwise. I can use Alt/Option to generate `@ # [ ] | { } … « »` and other characters.
It seems to me that Gnome is having an extra layer somewhere... But where? In the keyboard settings I specified “Any Alt key” as the “Key to choose 3rd level” – but that doesn’t seem to be Mode_switch.
Hm... `xmodmap -pm` prints the following:
xmodmap: up to 5 keys per modifier, (keycodes in parentheses): shift Shift_L (0x32), Shift_R (0x3e) lock Caps_Lock (0x42) control Control_L (0x25), Control_R (0x69) mod1 Alt_L (0xcc) mod2 Num_Lock (0x4d) mod3 mod4 Meta_L (0x85), Meta_R (0x86), Meta_L (0xcd), Super_L (0xce), Hyper_L (0xcf) mod5 ISO_Level3_Shift (0x40), ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
The Alt/Option key generates the keycode 64. `xmodmap -pke | grep " 64 "` shows:
keycode 64 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift NoSymbol ISO_Level3_Shift
So pressing Alt/Option is ISO_Level3_Shift, which acts as a mod5. That’s cool, because then I can use it bind window manager events.
Hm, perhaps that’s the answer to my problem? Is there an existing binding for Alt minus that has no visible effect?
`xmodmap -e "keycode 64 = Mode_switch"` does what I want to the minus key, but undoes the “third level” for all other keys – eg. Alt 3 should result in #. So that didn’t work.
I finally found references to `xkeyboard-config`, the Synaptic package manager led me to `xkb-data`, and the file list of that package to `/usr/share/X11/xkb` – and some grepping finally led me to believe that the following change should do the trick:
alex@orientalibombus:/usr/share/X11/xkb/symbols$ diff ch~ ch 39c39 < key <AB10> { [ minus, underscore ] }; --- > key <AB10> { [ minus, underscore, endash, emdash ] };
But alas, no luck! Confused, I decided to remove the `~/.Xmodmap` file I had created above, logout, login – and I was rewarded with a strange result: Alt minus results in the *soft hyphen* and Shift Alt minus results in the *em dash*! How did the endash get converted into a soft hyphen?
I spotted a different and decided to make a different change:
alex@orientalibombus:/usr/share/X11/xkb/symbols$ diff ch~ ch 188c188 < key <AB10> { [ minus, underscore, hyphen, emdash ]}; --- > key <AB10> { [ minus, underscore, endash, emdash ]};
And now it works as expected! 🙂
I have no idea how to make this change user-specific. Apparently the hyphen just didn’t work at all? I wonder why changing the “basic” layout activated the soft hyphen? Questions, questions. I feel like reporting a bug.
#Ubuntu