8

I'm using an aluminum Apple keyboard with my Mandriva 2010.2 Linux system. I remap the Apple Command key () to control using the following .Xmodmap file:

keycode 134 = Control_R
remove mod4 = Multi_key
add Control = Control_L Control_R Multi_key

If I allow xscreensaver to activate and run for some time, it appears to undo this remapping. I subsequently have to run xmodmap ~/.Xmodmap again manually.

Is there any way to avoid this? I'm using XFCE as my desktop environment.

AdminBee
  • 22,803
lebedov
  • 181
  • I've run into this before where things are able to reset any changes made by xmodmap after X starts and revert to the default X layout. VMware used to do this all the time. If I can remember what I did to fix it so that xmodmap wouldn't get over-written I'll get back to you on this. – Caleb Jul 04 '11 at 09:53
  • I'm getting the same problem, although I didn't pin it down to a screen saver, that's got me thinking, but all I know is that after some duration the xmodmap settings that I successfully applied automatically on login somehow revert all by themselves. I guess a workaround is to use another method to more permanently affect the bindings but I'd really like to know who is un-setting my xmodmap, or re-applying a keymap in the middle of a session without being asked. What did you discover, @Caleb? – NeilG Aug 22 '21 at 03:42
  • Also the same question here, although no useful answers at this time: https://stackoverflow.com/questions/27370024/xmodmap-deconfigures-automatically – NeilG Aug 22 '21 at 04:21
  • I did find a comment here that may help your situation https://forums.linuxmint.com/viewtopic.php?t=119441 which recommends "put your xmodmap script into the folder /etc/apm/scripts.d, then creating a symbolic link to it in /etc/apm/resume.d". Presumably this ensures the script is re-applied after power management may have interrupted. – NeilG Aug 22 '21 at 04:54
  • Just another clue in case it helps someone track down the culprit - I've just noticed that although my mappings don't revert due to a screensaver or power management state change, the revert may be associated with the bluetooth keyboard disconnecting on idle, and re-connecting. There may be some keyboard reset operation that gets run. – NeilG Aug 22 '21 at 05:54

2 Answers2

2

A few years ago I used a PC keyboard with a Macintosh multi-booting Mac OS 9, Mac OS X and Linux. The windows key generated the same keycode as the Apple Command Key and showed up in linux as 'meta' or something. Try geekosaur's answer for mapping the windows key here.

Even if it is the wrong keycode, something very similar should do for you.

Edit: Example of xorg.conf section to map the Control function to the Windows keys according to geekosaur's instructions.

Section "InputDevice"
    Identifier  "Keyboard0"
    Driver    "keyboard"
    Option    "XkbLayout" "us"
    Option    "XkbOptions" "altwin:ctrl_win"
EndSection
  • 1
    Setting the mapping isn't the problem here, the problem is it is getting UN-set by something else. – Caleb Jul 04 '11 at 09:51
  • This post describes how to make the change permanent when using xkb, but it seems that ~/.xkbmap or ~/.Xkbmap is not automatically parsed on my system when I start an X11 session. – lebedov Jul 04 '11 at 13:42
  • @Caleb, the important bit from geekosaur is the 'Section "InputDevices" ... XkbOptions "altwin:ctrl_win" ... EndSection' in /etc/X11/xorg.conf. This avoids the ~/.Xmodmap not loading, rogue window managers, and xscreensaver cannot touch it. – Magicianeer Jul 05 '11 at 04:25
1

You can simply permanently define another layout, or key bindings. Here:

how to assign another modifier to Alt key for X11?

greenoldman
  • 6,176