$ setxkbmap "pc+us+ir:2+inet(evdev)+group(shifts_toggle)"
I got that line by running setxkbmap -print
on my Ubuntu machine. The output had something that seemed to be what I
want. And I was right! Running that, I noticed that the changes I've
made with xmodmap was reset. Well, all I had to do was to put the line
that runs xmodmap after setxkbmap. Like this:Except that didn't work. I logged out and logged back in, and I saw my alt and ctrl keys are not where they should be. A couple of times running those commands by(run-shell-command "setxkbmap \"pc+us+ir:2+inet(evdev)+group(shifts_toggle)\"") ;; load keyboard map (run-shell-command "xmodmap ~/.xmodmap")
C-x C-e
from
within Emacs gave me an idea what might be wrong. You see, by default,
run-shell-command runs the command given to it asynchronously. I needed
to make sure setxkbmap is done before I move onto xmodmap. Thankfully, run-shell-command
has one last optional argument collect-output-p
.
It's function is to collect the program output, but in doing so it
makes the execution synchronous. So adding that argument fixed the
problem:Voila! Now I can switch layouts like before. Of course, I have no visual indication of the current layout anymore. I'm not 100% sure I want that. I might choose to work out a way for caps lock or scroll lock LED to do that for me later.(run-shell-command "setxkbmap \"pc+us+ir:2+inet(evdev)+group(shifts_toggle)\"" t)
UPDATE: If you want a visual indicator for the current keyboard layout, you can change the setxkbmap invokation to something like this:
This makes the CAPS LOCK led to turn on when an alternate keyboard layout is active.(run-shell-command "setxkbmap \"pc+us+ir:2+inet(evdev)+group(shifts_toggle)\" -option grp_led:caps" t)
No comments:
Post a Comment