`xmodmap` not working on startup

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I recently installed Debian 9 and inserted my usual ~/.Xmodmap file and added xmodmap ~/.Xmodmap to my .xsession. To my disappointment this didn't actually work.
For reference, I run i3 from startx without a DM.
To test if the command ran successfully I replaced the command in my .xsession with touch ~/prior && xmodmap ~/.Xmodmap && touch ~/post. And the files were in fact created indicating that the xmodmap command was indeed ran correctly but the mappings were reset somewhere, probably by a call to setxkbmap.
I searched for a solution and found only questions without answers, or questions with old answers that didn't work for me, or that contained no real solution:
Why won't my ~/.Xmodmap file load on login?- Why won't my xmodmap command run on startup/login?
- How do I set Xmodmap on login?
- Openbox overwrites xmodmap configuration
login xmodmap
add a comment |Â
up vote
0
down vote
favorite
I recently installed Debian 9 and inserted my usual ~/.Xmodmap file and added xmodmap ~/.Xmodmap to my .xsession. To my disappointment this didn't actually work.
For reference, I run i3 from startx without a DM.
To test if the command ran successfully I replaced the command in my .xsession with touch ~/prior && xmodmap ~/.Xmodmap && touch ~/post. And the files were in fact created indicating that the xmodmap command was indeed ran correctly but the mappings were reset somewhere, probably by a call to setxkbmap.
I searched for a solution and found only questions without answers, or questions with old answers that didn't work for me, or that contained no real solution:
Why won't my ~/.Xmodmap file load on login?- Why won't my xmodmap command run on startup/login?
- How do I set Xmodmap on login?
- Openbox overwrites xmodmap configuration
login xmodmap
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I recently installed Debian 9 and inserted my usual ~/.Xmodmap file and added xmodmap ~/.Xmodmap to my .xsession. To my disappointment this didn't actually work.
For reference, I run i3 from startx without a DM.
To test if the command ran successfully I replaced the command in my .xsession with touch ~/prior && xmodmap ~/.Xmodmap && touch ~/post. And the files were in fact created indicating that the xmodmap command was indeed ran correctly but the mappings were reset somewhere, probably by a call to setxkbmap.
I searched for a solution and found only questions without answers, or questions with old answers that didn't work for me, or that contained no real solution:
Why won't my ~/.Xmodmap file load on login?- Why won't my xmodmap command run on startup/login?
- How do I set Xmodmap on login?
- Openbox overwrites xmodmap configuration
login xmodmap
I recently installed Debian 9 and inserted my usual ~/.Xmodmap file and added xmodmap ~/.Xmodmap to my .xsession. To my disappointment this didn't actually work.
For reference, I run i3 from startx without a DM.
To test if the command ran successfully I replaced the command in my .xsession with touch ~/prior && xmodmap ~/.Xmodmap && touch ~/post. And the files were in fact created indicating that the xmodmap command was indeed ran correctly but the mappings were reset somewhere, probably by a call to setxkbmap.
I searched for a solution and found only questions without answers, or questions with old answers that didn't work for me, or that contained no real solution:
Why won't my ~/.Xmodmap file load on login?- Why won't my xmodmap command run on startup/login?
- How do I set Xmodmap on login?
- Openbox overwrites xmodmap configuration
login xmodmap
asked Nov 11 '17 at 23:00
Emily L.
1706
1706
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
I found the cause of this behavior to be indirectly documented in man keyboard:
DESCRIPTION
The keyboard file describes the properties of the keyboard. It is read by setupcon(1) in order to configure the keyboard on the console. In Debian systems the default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console.
The contents of /etc/default/keyboard are generated on system install and gave a hint to the actual problem (I added the ctrl:nocaps option later):
XKBMODEL="pc105"
XKBLAYOUT="se"
XKBVARIANT=""
XKBOPTIONS="ctrl:nocaps"
The above together indicates that X will set the xkb options at some point during startup (probably after .xsession and the like) which causes any xmodmap settings set during .xsession to be lost.
So there is the cause, the solution is hinted at from man setupcon:
The keyboard configuration is specified in ~/.keyboard or /etc/default/keyboard. The font configuration is specified in ~/.console-setup or /etc/default/console-setup.
Checking man console-setup yields:
The file console-setup specifies the encoding and the font to be used by setupcon(1) in order to setup the console. It can be used also to specify the keyboard layout but it is not recommended to do so, use keyboard(5) instead.
So /etc/default/keyboard is used to set keyboard settings for TTY and X. While /etc/default/console-setup is can be used to setup keyboard (not really recommended but works) and font for console only.
So to make this all work I moved /etc/default/keyboard to /etc/default/console-setup and added the following to my .xsession:
#!/bin/bash
# The below assumes bash features, rewrite if you use other shells.
source /etc/default/console-setup
XKBPARMS=""
if [[ "$XKBLAYOUT" ]]; then
XKBPARMS="-layout $XKBLAYOUT"
fi
if [[ "$XKBMODEL" ]]; then
XKBPARMS+=" -model $XKBMODEL"
fi
if [[ "$XKBVARIANT" ]]; then
XKBPARMS+=" -variant $XKBVARIANT"
fi
if [[ "$XKBOPTIONS" ]]; then
XKBPARMS+=" -option $XKBOPTIONS"
fi
if [[ "$XKBPARMS" ]]; then
setxkbmap $XKBPARMS
fi
xmodmap ~/.Xmodmap
Now xmodmap works correctly and I have the correct keymap and options in both the TTY and in X.
add a comment |Â
up vote
1
down vote
I don't have enough rep to write this as a comment -- as it is more of an alternative solution than a direct one to your issue -- but I was hoping it might help.
I'm by no means an expert, but I was also having issues with xmodmap-type solutions, so after some research I decided to use xkb directly. I also found that the archwiki does not recommend xmodmap for anything but "the simplest" tasks:
Generally it is not recommended to use xmodmap, except maybe for the simplest tasks. XKB-compatible equivalent of xmodmap is xkbcomp; however, xkbcomp lacks -e option, so it is not that simple. Anyway, whenever possible, xkbcomp should be preferred.
The following solution worked for me (on Ubuntu 16.04):
- In TTYs: how-to-change-console-keymap-in-linux.
- In
X: backup and modify the relevant files in/usr/share/X11/xkb/symbols/. I have changes inus(for number row and a few other things) andpc(for capslock).
Unfortunately, this does mean keeping track of two separate solutions for X and the TTY, but it's been alright with me so far.
But if you have an xmodmap solution that works already, that's all that matters!
Yes, I looked atxkbbut it seemed way too complicated for the equivalentxmodmap. Specifically I remap rightCtrlto becomeMod3instead of functioning as a control modifier. This becomes my mod key for i3 which is easier to use on my hands than theWinwhich breaks my fingers andAltconflicts with just about every other keybinding I use. But thanks for the comment, I'm sure it will be useful to someone who doesn't have a weird key rebinding schema. :)
â Emily L.
Nov 12 '17 at 11:14
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I found the cause of this behavior to be indirectly documented in man keyboard:
DESCRIPTION
The keyboard file describes the properties of the keyboard. It is read by setupcon(1) in order to configure the keyboard on the console. In Debian systems the default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console.
The contents of /etc/default/keyboard are generated on system install and gave a hint to the actual problem (I added the ctrl:nocaps option later):
XKBMODEL="pc105"
XKBLAYOUT="se"
XKBVARIANT=""
XKBOPTIONS="ctrl:nocaps"
The above together indicates that X will set the xkb options at some point during startup (probably after .xsession and the like) which causes any xmodmap settings set during .xsession to be lost.
So there is the cause, the solution is hinted at from man setupcon:
The keyboard configuration is specified in ~/.keyboard or /etc/default/keyboard. The font configuration is specified in ~/.console-setup or /etc/default/console-setup.
Checking man console-setup yields:
The file console-setup specifies the encoding and the font to be used by setupcon(1) in order to setup the console. It can be used also to specify the keyboard layout but it is not recommended to do so, use keyboard(5) instead.
So /etc/default/keyboard is used to set keyboard settings for TTY and X. While /etc/default/console-setup is can be used to setup keyboard (not really recommended but works) and font for console only.
So to make this all work I moved /etc/default/keyboard to /etc/default/console-setup and added the following to my .xsession:
#!/bin/bash
# The below assumes bash features, rewrite if you use other shells.
source /etc/default/console-setup
XKBPARMS=""
if [[ "$XKBLAYOUT" ]]; then
XKBPARMS="-layout $XKBLAYOUT"
fi
if [[ "$XKBMODEL" ]]; then
XKBPARMS+=" -model $XKBMODEL"
fi
if [[ "$XKBVARIANT" ]]; then
XKBPARMS+=" -variant $XKBVARIANT"
fi
if [[ "$XKBOPTIONS" ]]; then
XKBPARMS+=" -option $XKBOPTIONS"
fi
if [[ "$XKBPARMS" ]]; then
setxkbmap $XKBPARMS
fi
xmodmap ~/.Xmodmap
Now xmodmap works correctly and I have the correct keymap and options in both the TTY and in X.
add a comment |Â
up vote
1
down vote
I found the cause of this behavior to be indirectly documented in man keyboard:
DESCRIPTION
The keyboard file describes the properties of the keyboard. It is read by setupcon(1) in order to configure the keyboard on the console. In Debian systems the default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console.
The contents of /etc/default/keyboard are generated on system install and gave a hint to the actual problem (I added the ctrl:nocaps option later):
XKBMODEL="pc105"
XKBLAYOUT="se"
XKBVARIANT=""
XKBOPTIONS="ctrl:nocaps"
The above together indicates that X will set the xkb options at some point during startup (probably after .xsession and the like) which causes any xmodmap settings set during .xsession to be lost.
So there is the cause, the solution is hinted at from man setupcon:
The keyboard configuration is specified in ~/.keyboard or /etc/default/keyboard. The font configuration is specified in ~/.console-setup or /etc/default/console-setup.
Checking man console-setup yields:
The file console-setup specifies the encoding and the font to be used by setupcon(1) in order to setup the console. It can be used also to specify the keyboard layout but it is not recommended to do so, use keyboard(5) instead.
So /etc/default/keyboard is used to set keyboard settings for TTY and X. While /etc/default/console-setup is can be used to setup keyboard (not really recommended but works) and font for console only.
So to make this all work I moved /etc/default/keyboard to /etc/default/console-setup and added the following to my .xsession:
#!/bin/bash
# The below assumes bash features, rewrite if you use other shells.
source /etc/default/console-setup
XKBPARMS=""
if [[ "$XKBLAYOUT" ]]; then
XKBPARMS="-layout $XKBLAYOUT"
fi
if [[ "$XKBMODEL" ]]; then
XKBPARMS+=" -model $XKBMODEL"
fi
if [[ "$XKBVARIANT" ]]; then
XKBPARMS+=" -variant $XKBVARIANT"
fi
if [[ "$XKBOPTIONS" ]]; then
XKBPARMS+=" -option $XKBOPTIONS"
fi
if [[ "$XKBPARMS" ]]; then
setxkbmap $XKBPARMS
fi
xmodmap ~/.Xmodmap
Now xmodmap works correctly and I have the correct keymap and options in both the TTY and in X.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I found the cause of this behavior to be indirectly documented in man keyboard:
DESCRIPTION
The keyboard file describes the properties of the keyboard. It is read by setupcon(1) in order to configure the keyboard on the console. In Debian systems the default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console.
The contents of /etc/default/keyboard are generated on system install and gave a hint to the actual problem (I added the ctrl:nocaps option later):
XKBMODEL="pc105"
XKBLAYOUT="se"
XKBVARIANT=""
XKBOPTIONS="ctrl:nocaps"
The above together indicates that X will set the xkb options at some point during startup (probably after .xsession and the like) which causes any xmodmap settings set during .xsession to be lost.
So there is the cause, the solution is hinted at from man setupcon:
The keyboard configuration is specified in ~/.keyboard or /etc/default/keyboard. The font configuration is specified in ~/.console-setup or /etc/default/console-setup.
Checking man console-setup yields:
The file console-setup specifies the encoding and the font to be used by setupcon(1) in order to setup the console. It can be used also to specify the keyboard layout but it is not recommended to do so, use keyboard(5) instead.
So /etc/default/keyboard is used to set keyboard settings for TTY and X. While /etc/default/console-setup is can be used to setup keyboard (not really recommended but works) and font for console only.
So to make this all work I moved /etc/default/keyboard to /etc/default/console-setup and added the following to my .xsession:
#!/bin/bash
# The below assumes bash features, rewrite if you use other shells.
source /etc/default/console-setup
XKBPARMS=""
if [[ "$XKBLAYOUT" ]]; then
XKBPARMS="-layout $XKBLAYOUT"
fi
if [[ "$XKBMODEL" ]]; then
XKBPARMS+=" -model $XKBMODEL"
fi
if [[ "$XKBVARIANT" ]]; then
XKBPARMS+=" -variant $XKBVARIANT"
fi
if [[ "$XKBOPTIONS" ]]; then
XKBPARMS+=" -option $XKBOPTIONS"
fi
if [[ "$XKBPARMS" ]]; then
setxkbmap $XKBPARMS
fi
xmodmap ~/.Xmodmap
Now xmodmap works correctly and I have the correct keymap and options in both the TTY and in X.
I found the cause of this behavior to be indirectly documented in man keyboard:
DESCRIPTION
The keyboard file describes the properties of the keyboard. It is read by setupcon(1) in order to configure the keyboard on the console. In Debian systems the default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console.
The contents of /etc/default/keyboard are generated on system install and gave a hint to the actual problem (I added the ctrl:nocaps option later):
XKBMODEL="pc105"
XKBLAYOUT="se"
XKBVARIANT=""
XKBOPTIONS="ctrl:nocaps"
The above together indicates that X will set the xkb options at some point during startup (probably after .xsession and the like) which causes any xmodmap settings set during .xsession to be lost.
So there is the cause, the solution is hinted at from man setupcon:
The keyboard configuration is specified in ~/.keyboard or /etc/default/keyboard. The font configuration is specified in ~/.console-setup or /etc/default/console-setup.
Checking man console-setup yields:
The file console-setup specifies the encoding and the font to be used by setupcon(1) in order to setup the console. It can be used also to specify the keyboard layout but it is not recommended to do so, use keyboard(5) instead.
So /etc/default/keyboard is used to set keyboard settings for TTY and X. While /etc/default/console-setup is can be used to setup keyboard (not really recommended but works) and font for console only.
So to make this all work I moved /etc/default/keyboard to /etc/default/console-setup and added the following to my .xsession:
#!/bin/bash
# The below assumes bash features, rewrite if you use other shells.
source /etc/default/console-setup
XKBPARMS=""
if [[ "$XKBLAYOUT" ]]; then
XKBPARMS="-layout $XKBLAYOUT"
fi
if [[ "$XKBMODEL" ]]; then
XKBPARMS+=" -model $XKBMODEL"
fi
if [[ "$XKBVARIANT" ]]; then
XKBPARMS+=" -variant $XKBVARIANT"
fi
if [[ "$XKBOPTIONS" ]]; then
XKBPARMS+=" -option $XKBOPTIONS"
fi
if [[ "$XKBPARMS" ]]; then
setxkbmap $XKBPARMS
fi
xmodmap ~/.Xmodmap
Now xmodmap works correctly and I have the correct keymap and options in both the TTY and in X.
edited Nov 12 '17 at 0:35
answered Nov 11 '17 at 23:00
Emily L.
1706
1706
add a comment |Â
add a comment |Â
up vote
1
down vote
I don't have enough rep to write this as a comment -- as it is more of an alternative solution than a direct one to your issue -- but I was hoping it might help.
I'm by no means an expert, but I was also having issues with xmodmap-type solutions, so after some research I decided to use xkb directly. I also found that the archwiki does not recommend xmodmap for anything but "the simplest" tasks:
Generally it is not recommended to use xmodmap, except maybe for the simplest tasks. XKB-compatible equivalent of xmodmap is xkbcomp; however, xkbcomp lacks -e option, so it is not that simple. Anyway, whenever possible, xkbcomp should be preferred.
The following solution worked for me (on Ubuntu 16.04):
- In TTYs: how-to-change-console-keymap-in-linux.
- In
X: backup and modify the relevant files in/usr/share/X11/xkb/symbols/. I have changes inus(for number row and a few other things) andpc(for capslock).
Unfortunately, this does mean keeping track of two separate solutions for X and the TTY, but it's been alright with me so far.
But if you have an xmodmap solution that works already, that's all that matters!
Yes, I looked atxkbbut it seemed way too complicated for the equivalentxmodmap. Specifically I remap rightCtrlto becomeMod3instead of functioning as a control modifier. This becomes my mod key for i3 which is easier to use on my hands than theWinwhich breaks my fingers andAltconflicts with just about every other keybinding I use. But thanks for the comment, I'm sure it will be useful to someone who doesn't have a weird key rebinding schema. :)
â Emily L.
Nov 12 '17 at 11:14
add a comment |Â
up vote
1
down vote
I don't have enough rep to write this as a comment -- as it is more of an alternative solution than a direct one to your issue -- but I was hoping it might help.
I'm by no means an expert, but I was also having issues with xmodmap-type solutions, so after some research I decided to use xkb directly. I also found that the archwiki does not recommend xmodmap for anything but "the simplest" tasks:
Generally it is not recommended to use xmodmap, except maybe for the simplest tasks. XKB-compatible equivalent of xmodmap is xkbcomp; however, xkbcomp lacks -e option, so it is not that simple. Anyway, whenever possible, xkbcomp should be preferred.
The following solution worked for me (on Ubuntu 16.04):
- In TTYs: how-to-change-console-keymap-in-linux.
- In
X: backup and modify the relevant files in/usr/share/X11/xkb/symbols/. I have changes inus(for number row and a few other things) andpc(for capslock).
Unfortunately, this does mean keeping track of two separate solutions for X and the TTY, but it's been alright with me so far.
But if you have an xmodmap solution that works already, that's all that matters!
Yes, I looked atxkbbut it seemed way too complicated for the equivalentxmodmap. Specifically I remap rightCtrlto becomeMod3instead of functioning as a control modifier. This becomes my mod key for i3 which is easier to use on my hands than theWinwhich breaks my fingers andAltconflicts with just about every other keybinding I use. But thanks for the comment, I'm sure it will be useful to someone who doesn't have a weird key rebinding schema. :)
â Emily L.
Nov 12 '17 at 11:14
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I don't have enough rep to write this as a comment -- as it is more of an alternative solution than a direct one to your issue -- but I was hoping it might help.
I'm by no means an expert, but I was also having issues with xmodmap-type solutions, so after some research I decided to use xkb directly. I also found that the archwiki does not recommend xmodmap for anything but "the simplest" tasks:
Generally it is not recommended to use xmodmap, except maybe for the simplest tasks. XKB-compatible equivalent of xmodmap is xkbcomp; however, xkbcomp lacks -e option, so it is not that simple. Anyway, whenever possible, xkbcomp should be preferred.
The following solution worked for me (on Ubuntu 16.04):
- In TTYs: how-to-change-console-keymap-in-linux.
- In
X: backup and modify the relevant files in/usr/share/X11/xkb/symbols/. I have changes inus(for number row and a few other things) andpc(for capslock).
Unfortunately, this does mean keeping track of two separate solutions for X and the TTY, but it's been alright with me so far.
But if you have an xmodmap solution that works already, that's all that matters!
I don't have enough rep to write this as a comment -- as it is more of an alternative solution than a direct one to your issue -- but I was hoping it might help.
I'm by no means an expert, but I was also having issues with xmodmap-type solutions, so after some research I decided to use xkb directly. I also found that the archwiki does not recommend xmodmap for anything but "the simplest" tasks:
Generally it is not recommended to use xmodmap, except maybe for the simplest tasks. XKB-compatible equivalent of xmodmap is xkbcomp; however, xkbcomp lacks -e option, so it is not that simple. Anyway, whenever possible, xkbcomp should be preferred.
The following solution worked for me (on Ubuntu 16.04):
- In TTYs: how-to-change-console-keymap-in-linux.
- In
X: backup and modify the relevant files in/usr/share/X11/xkb/symbols/. I have changes inus(for number row and a few other things) andpc(for capslock).
Unfortunately, this does mean keeping track of two separate solutions for X and the TTY, but it's been alright with me so far.
But if you have an xmodmap solution that works already, that's all that matters!
answered Nov 12 '17 at 3:48
nivk
285
285
Yes, I looked atxkbbut it seemed way too complicated for the equivalentxmodmap. Specifically I remap rightCtrlto becomeMod3instead of functioning as a control modifier. This becomes my mod key for i3 which is easier to use on my hands than theWinwhich breaks my fingers andAltconflicts with just about every other keybinding I use. But thanks for the comment, I'm sure it will be useful to someone who doesn't have a weird key rebinding schema. :)
â Emily L.
Nov 12 '17 at 11:14
add a comment |Â
Yes, I looked atxkbbut it seemed way too complicated for the equivalentxmodmap. Specifically I remap rightCtrlto becomeMod3instead of functioning as a control modifier. This becomes my mod key for i3 which is easier to use on my hands than theWinwhich breaks my fingers andAltconflicts with just about every other keybinding I use. But thanks for the comment, I'm sure it will be useful to someone who doesn't have a weird key rebinding schema. :)
â Emily L.
Nov 12 '17 at 11:14
Yes, I looked at
xkb but it seemed way too complicated for the equivalent xmodmap. Specifically I remap right Ctrl to become Mod3 instead of functioning as a control modifier. This becomes my mod key for i3 which is easier to use on my hands than the Win which breaks my fingers and Alt conflicts with just about every other keybinding I use. But thanks for the comment, I'm sure it will be useful to someone who doesn't have a weird key rebinding schema. :)â Emily L.
Nov 12 '17 at 11:14
Yes, I looked at
xkb but it seemed way too complicated for the equivalent xmodmap. Specifically I remap right Ctrl to become Mod3 instead of functioning as a control modifier. This becomes my mod key for i3 which is easier to use on my hands than the Win which breaks my fingers and Alt conflicts with just about every other keybinding I use. But thanks for the comment, I'm sure it will be useful to someone who doesn't have a weird key rebinding schema. :)â Emily L.
Nov 12 '17 at 11:14
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f403962%2fxmodmap-not-working-on-startup%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password