0

I have a .xmodmap file stored in my home directory ( I am using Debian 9.0 and Gnome). When I activate with a command

$xmodmap $HOME/.Xmodmap

in the terminal, everything is fine. But when I enter again the above command in the terminal, it deactivates my defined keys ( I loose my defined keys in .Xmodmap.) This is problematic for me, because I put the above command in .bashrc file. Whenever I open a new terminal, the defined keys in my .Xmodmap become activated or deactivated because of the problem mentioned above. A few terminals behave like no having .Xmodmap, on the other hand, other terminals are normal with .Xmodmap

Here is my .Xmodmap file:

remove Mod1 = Alt_L Meta_L Alt_L Meta_L
remove Mod5 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift
clear lock
keysym Alt_L Meta_L Alt_L Meta_L = ISO_Level3_Shift NoSymbol ISO_Level3_Shift
keysym ISO_Level3_Shift NoSymbol ISO_Level3_Shift = Alt_L Meta_L Alt_L Meta_L
keycode  94 = x X backslash bar grave dead_grave backslash bar
!keycode  51 = Escape


keycode  44 = k K j J  less j J
keycode  45 = m M k K  greater k K
keycode  46 = l L l L bar VoidSymbol l L

!keycode 66 = Meta_L

! swap  "Menu Key" to Ctrl
remove Control = Control_R
keycode 135 = Control_R Control_R Control_R Control_R
keycode 66  = Meta_L

add Control = Control_R

add Mod1 = Alt_L Meta_L
add Mod5 = ISO_Level3_Shift
! Swap the Caps Lock and Escape keys

!remove Lock = Caps_Lock
!keysym Escape = Caps_Lock
!add Lock = Caps_Lock
  • 1
    Didn't check in detail why the xmodmap file is not idempotent, but putting session-related files into .bashrc isn't really optimal. Consider putting it instead into .xsession, or whatever your display manager (gdm? kdm? xdm?) executes upon session startup (the man-pages should tell you). – dirkt Jul 21 '17 at 11:24
  • 1
    In @dirkt's comment, read “isn't really optimal” as “doesn't make any sense because it can't work usefully” and “Consider putting it” as “Put it”. Since you use Gnome, put it in your setup applications (search this site if you need help, this has come up before). I don't see at first glance why running it again doesn't work, but if you put it in .bashrc, it wouldn't even be available until you first open a terminal. .bashrc is for bash settings only. – Gilles Jul 21 '17 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.