Score:0

Xmodmap: How to get Xmodmap on autostart

cn flag

I am using "Ubuntu Xorg" inside of Ubuntu 21.10, cause on normal Ubuntu it was not possible for me to set up xmodmap inside of gnome applications (e.g. Firefox, LibreOffice, Terminal). My aim with xmodmap is to reconfigure the keys "AltGr" + "y" and "AltGr" + "x". And I don't found some other applications inside of Linux to do that.

My wish now is to fix the settings on login. So I worked all the solutions from this post, but nothing helps. This solutions are working inside of the other Ubuntu configuration, but not inside of Ubunto Xorg. How can I set xmodmap on autostart inside of Ubuntu Xorg?

user10489 avatar
in flag
The correct solution is to use xkb instead of xmodmap, but it's not as easy. xmodmap is all but obsolete due to internationalization changes.
user10489 avatar
in flag
gnome-shell and the internationalization keyboard selector step on xmodmap, so even if you do get it working on startup, it gets reset by other things.
Score:1
se flag

You could try to add this to your shell start profile for example. It should work if you've set a terminal as a startup application. However, it might slowdown subsequent terminals. But probably only on first launch. You will need to modify this to check for what your particular remap value will return.

# ~/.zshrc
mysetting=$(xmodmap -pke | grep 135)
if [ $mysetting != 'keycode 135 = Control_R NoSymbol Control_R' ]; then
  sleep 4 && xmodmap ~/.Xmodmap &
fi

user10489 avatar
in flag
not sure why the sleep would be needed.
lacostenycoder avatar
se flag
@user10489 it's there for safety in case something else at boot overrides. You may not need it.
user10489 avatar
in flag
If you use xkb instead of xmodmap, that problem goes away.
lacostenycoder avatar
se flag
@user10489 I had tried that but wasn't able to get it to work. Perhaps you can point me to a working example or perhaps post an answer?
user10489 avatar
in flag
Ask another question about that, explain what you tried.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.