How to make a key remap stick through reboots?
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
How to make a key remap stick through reboots?
I have tried seemingly everything but nothing seems to survive a reboot.
I have made a .Xmodmap in my homedir that remaps the windows key as F14 so I can use it to launch synapse.
I am able to apply it when already logged in using the command:
xmodmap /home/shimi/.Xmodmap
but any method I have found online to make it permanent doesn't work.
The first time I log in after making that file I'm asked by MATE if I want to load it and if to ask every time. I load it and tell it not to ask again. It doesn't work the next time.
I tried making a bash script that runs said command, make it executable and add it to startup applications, but that didn't help either.
tried adding the line to .xinitrc, to /etc/X11/Xsession, to /etc/mdm/Xsession.. absolutely nothing seems to work.
However after I'm logged in and everything loads, opening a terminal and running the command successfully remaps the key.
I'm completely baffled.
Any idea how to make this change permanent?
I have made a .Xmodmap in my homedir that remaps the windows key as F14 so I can use it to launch synapse.
I am able to apply it when already logged in using the command:
xmodmap /home/shimi/.Xmodmap
but any method I have found online to make it permanent doesn't work.
The first time I log in after making that file I'm asked by MATE if I want to load it and if to ask every time. I load it and tell it not to ask again. It doesn't work the next time.
I tried making a bash script that runs said command, make it executable and add it to startup applications, but that didn't help either.
tried adding the line to .xinitrc, to /etc/X11/Xsession, to /etc/mdm/Xsession.. absolutely nothing seems to work.
However after I'm logged in and everything loads, opening a terminal and running the command successfully remaps the key.
I'm completely baffled.
Any idea how to make this change permanent?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: How to make a key remap stick through reboots?
Solution which worked for me (Linux Mint 13 MATE):
I created a file /home/<user>/mapkeys with the following 1-line content:
xmodmap /home/<user>/.Xmodmap
and then I used the following command to be executed via startup applications (Menu->Preferences->Startup Applications):
bash /home/<user>/mapkeys
I created a file /home/<user>/mapkeys with the following 1-line content:
xmodmap /home/<user>/.Xmodmap
and then I used the following command to be executed via startup applications (Menu->Preferences->Startup Applications):
bash /home/<user>/mapkeys
Re: How to make a key remap stick through reboots?
Thanks but that doesn't work either :\
There is some voodoo going on here...
Running bash /home/<user>/mapkeys from terminal works but as a startup item doesn't do anything.
There is some voodoo going on here...
Running bash /home/<user>/mapkeys from terminal works but as a startup item doesn't do anything.
Re: How to make a key remap stick through reboots?
I'm having the exact same problem. With a US keboard laptop, all I want to do is map the dollar key (Shift-4) to the pound sign. That's easy enough with the command:
But to make it stick after a reboot is proving very difficult. Adding that line to the .xinitrc file in my home directory and making that file executable ought to do the trick, as this file ought to be run as a script at start up. But it doesn't work.
Does anyone know why this doesn't work, and what the solution is?
Code: Select all
xmodmap -e "keycode 13 = 4 sterling"
Does anyone know why this doesn't work, and what the solution is?
Re: How to make a key remap stick through reboots?
No further comments on this - can anyone help?
To re-map the Dollar symbol (shift-4) to a Pound symbol on a US keyboard, I create a file ~/.xinitrc and make it executable. In it I put:
If I run that script at the console, bingo - I get my Pound sign. But it won't auto-run! I understood that Linux Mint should run the script automatically at boot time - I thought that was its purpose - but apparently not.
The other thing I have tried is adding the following line to the file /etc/X11/xinit/xinitrc:
That script is obviously run in order to invoke the global X session script /etc/X11/Xsession. But my line of code doesn't run!
It MUST surely be possible in Linux Mint to run a script at start-up! Does anyone know what is going on here?
To re-map the Dollar symbol (shift-4) to a Pound symbol on a US keyboard, I create a file ~/.xinitrc and make it executable. In it I put:
Code: Select all
#!/bin/bash
# Remap the "4" key so that "shift-4" produces a pound sign instead of a dollar sign
xmodmap -e "keycode 13 = 4 sterling"
The other thing I have tried is adding the following line to the file /etc/X11/xinit/xinitrc:
Code: Select all
# Remap the "4" key so that "shift-4" produces a pound sign instead of a dollar sign
xmodmap -e "keycode 13 = 4 sterling"
It MUST surely be possible in Linux Mint to run a script at start-up! Does anyone know what is going on here?
Re: How to make a key remap stick through reboots?
Ok, found my own answer, though a bit disappointing that no-one has been able to help out with the solution to this simple question. My particular key remap is to replace the Dollar key with a Pound sign, but any other key remap will of course work, and any other script can be run in a similar fashion.
Here's how (Linux Mint Cinnamon):
1. Create a folder called "Startup" in home folder ~/ (i.e. in the folder /home/<myname>/)
2. In that folder create a text file called "PoundNotDollar.sh" containing the following lines:
3. Make that script executable: chmod 755 ~/Startup/PoundNotDollar.sh
4. Go to <Menu><All Applications><Startup Applications>
Click "+ Add" and add the script, giving the Name as "PoundNotDollar" and the Command as "~/Startup/PoundNotDollar.sh"
The script will run on boot, and your dollar key will now map to a pound sign.
Here's how (Linux Mint Cinnamon):
1. Create a folder called "Startup" in home folder ~/ (i.e. in the folder /home/<myname>/)
2. In that folder create a text file called "PoundNotDollar.sh" containing the following lines:
Code: Select all
#!/bin/bash
# Purpose - remap the "4" key so that "shift-4" produces a pound sign instead of a dollar sign
xmodmap -e "keycode 13 = 4 sterling"
4. Go to <Menu><All Applications><Startup Applications>
Click "+ Add" and add the script, giving the Name as "PoundNotDollar" and the Command as "~/Startup/PoundNotDollar.sh"
The script will run on boot, and your dollar key will now map to a pound sign.
Re: How to make a key remap stick through reboots?
This is by far the most simple and effective (without jumping through a million hoops) method of remapping the keys. Unfortunately I can't for the life of me get anything to run at startup, I'm on the latest mint 14 with xfce 4.10. So here the application startup is in menu/settings/sessions and startup and there is an applications startup tab, which, whatever you add to it doesn't start at startup. So, am stumped. Any other ideas?
Re: How to make a key remap stick through reboots?
I'm afraid I can't help you with Xfce on Mint 14 - What I've said only reliably applies to Mint 14 Cinnamon.
Anyhow, I'm not entirely out of the woods yet myself. I have two startup scripts; one to mount a remote CIFS share, the other to re-assign the dollar key to a pound sign. When I restart, both of these scripts run satisfactorily. When I log off and back on again, they are still running. But if I let the machine or put the machine into sleep mode, when it restarts, the CIFS mount is still mounted, but the keyboard has reverted to producing a $ sign instead of Pound sign! Can anyone shed any light on why this might be?
Anyhow, I'm not entirely out of the woods yet myself. I have two startup scripts; one to mount a remote CIFS share, the other to re-assign the dollar key to a pound sign. When I restart, both of these scripts run satisfactorily. When I log off and back on again, they are still running. But if I let the machine or put the machine into sleep mode, when it restarts, the CIFS mount is still mounted, but the keyboard has reverted to producing a $ sign instead of Pound sign! Can anyone shed any light on why this might be?
Re: How to make a key remap stick through reboots?
I'm new here so sorry if this isn't formatted properly.
To sectionq,
I'm also using the Mint 14 with xfce 4.10, and I used setxkbmap as a workaround. There's a full list of setxkbmap option codes in /usr/share/X11/xkb/rules/xorg.lst but for remapping control to caps lock all you need to do is go to Settings-->Session and Startup
Under the applications and autostart tab add an application with the following command
Hope that helps
To sectionq,
I'm also using the Mint 14 with xfce 4.10, and I used setxkbmap as a workaround. There's a full list of setxkbmap option codes in /usr/share/X11/xkb/rules/xorg.lst but for remapping control to caps lock all you need to do is go to Settings-->Session and Startup
Under the applications and autostart tab add an application with the following command
Code: Select all
/usr/bin/setxkbmap -option "ctrl:nocaps"
Re: How to make a key remap stick through reboots?
Thanks, I'll give that a try. I was forgetting that in the command box you could also (and need) to put terminal commands in also. I've just been linking to the address so that has probably been the problem all along.
Re: How to make a key remap stick through reboots?
Well, I think I may have cracked that one too by putting the script PoundNotDollar.sh into the folder /etc/apm/scripts.d, then creating a symbolic link to it in /etc/apm/resume.d:pmorton wrote:Anyhow, I'm not entirely out of the woods yet myself. I have two startup scripts; one to mount a remote CIFS share, the other to re-assign the dollar key to a pound sign. When I restart, both of these scripts run satisfactorily. When I log off and back on again, they are still running. But if I let (or put) the machine into sleep mode, when it restarts, the CIFS mount is still mounted, but the keyboard has reverted to producing a $ sign instead of Pound sign! Can anyone shed any light on why this might be?
Code: Select all
sudo ln -s /etc/apm/scripts.d/PoundNotDollar.sh /etc/apm/resume.d/PoundNotDollar.sh
Re: How to make a key remap stick through reboots?
Putting my keyboard mapping in .Xmodmap works fine for me. I am running Mint 13 and xmonad wm.
Maybe it will help whomever is still having trouble to read through the "/etc/mdm/Xsession" script. It is pretty well commented and may explain why your script isn't running. Reading through the Xsession script, it looks like .xsession .xsessionrc and .Xsession are all defined, but never used. I don't know why that is, but you could add a "eval exec $USERXSESSION" somewhere in the Xsession script to get .xsession called from your home folder.
GL
Maybe it will help whomever is still having trouble to read through the "/etc/mdm/Xsession" script. It is pretty well commented and may explain why your script isn't running. Reading through the Xsession script, it looks like .xsession .xsessionrc and .Xsession are all defined, but never used. I don't know why that is, but you could add a "eval exec $USERXSESSION" somewhere in the Xsession script to get .xsession called from your home folder.
GL
Re: How to make a key remap stick through reboots?
I discovered that using .xsessionrc does work! At least it did for me running xmonad. I found this in the /etc/X11/Xsession.d/40x11-common_xsessionrc file. That file should probably also run .xsession and/or .xinitrc too. I guess this was a decision by the mint team to stick with only one x init file in the home directory.
Re: How to make a key remap stick through reboots?
Hi,
I put the command xmodmap ~/.Xmodmap in a file ~/.xsessionrc and made the file executable. It still doesn't work. Any idea what I am doing wrong?
Thanks
I put the command xmodmap ~/.Xmodmap in a file ~/.xsessionrc and made the file executable. It still doesn't work. Any idea what I am doing wrong?
Thanks
Re: How to make a key remap stick through reboots?
Anyone ever solve this? Im so stuck on it..
I added some logger commands to the Xsession file, where it loads the ~/.Xmodmap, and it loads it, I had it log $? to see if it failed, and it logs a 0 (success).
I even created ~/.xprofile, which is just executing the xmodmap ~/.Xmodmap, and it executes it just fine. Even specifies the -display as :0
ALL WORKS OK!
But the keys wont actually work... Unless I run xmodmap ~/.Xmodmap manually from the command line...
IM GOING CRAZY!
I added some logger commands to the Xsession file, where it loads the ~/.Xmodmap, and it loads it, I had it log $? to see if it failed, and it logs a 0 (success).
I even created ~/.xprofile, which is just executing the xmodmap ~/.Xmodmap, and it executes it just fine. Even specifies the -display as :0
ALL WORKS OK!
But the keys wont actually work... Unless I run xmodmap ~/.Xmodmap manually from the command line...
IM GOING CRAZY!
Re: How to make a key remap stick through reboots?
I've found a solution, although it's the kludgiest kludge I've ever kludged:
Make a script called, say, ~/.keymapping.sh and make it executable. Put in it:
#!/bin/sh
sleep 2
xmodmap ~/.Xmodmap
And make it run on startup. The two second delay makes it happen after whatever it is that's overriding the normal .Xmodmap settings happens, writing them back to the way you want. You don't get your custom keymaps for the first two seconds of each session, but it works otherwise.
Make a script called, say, ~/.keymapping.sh and make it executable. Put in it:
#!/bin/sh
sleep 2
xmodmap ~/.Xmodmap
And make it run on startup. The two second delay makes it happen after whatever it is that's overriding the normal .Xmodmap settings happens, writing them back to the way you want. You don't get your custom keymaps for the first two seconds of each session, but it works otherwise.
Re: How to make a key remap stick through reboots?
I've been having similar problems with my new installation of LM 17 Mate. The system only accepts my xmodmap settings if I input them in the terminal, or if I use the sleep command as above.
I notice that the system also seems to revert my xmodmap settings if I tap the "windows" key. Either that, or when I do something else that I haven't been able to pin down. This can get really hairy, as I sometimes don't notice that I've accidentally reverted my xmodmap settings, and then caps lock, and then notice that caps lock is on, so I run the xmodmap script... only to find that I've turned off caps lock while I already had caps lock on, meaning that everything is caps locked and the only way to turn it off is to log out and back in.
Interestingly, the first time I hit the windows key, the LM start window appears, but then on second and subsequent uses, my correct xmodmap setting (â) kicks in.
It looks like something is telling the system to ignore or try to revert xmodmap settings, and I'm not sure what.
It would be nice if the keyboard settings in LM17 would allow for open-ended setting of key bindings. As it is, the drop-down radio buttons and the variety of choices are nice, but nowhere near all the possibilities I want. Also, my guess is that that program is the culprit in these xmodmap problems. I don't remember having seen those settings in previous versions of LM, and I didn't have these xmodmap reversion problems in previous versions.
I notice that the system also seems to revert my xmodmap settings if I tap the "windows" key. Either that, or when I do something else that I haven't been able to pin down. This can get really hairy, as I sometimes don't notice that I've accidentally reverted my xmodmap settings, and then caps lock, and then notice that caps lock is on, so I run the xmodmap script... only to find that I've turned off caps lock while I already had caps lock on, meaning that everything is caps locked and the only way to turn it off is to log out and back in.
Interestingly, the first time I hit the windows key, the LM start window appears, but then on second and subsequent uses, my correct xmodmap setting (â) kicks in.
It looks like something is telling the system to ignore or try to revert xmodmap settings, and I'm not sure what.
It would be nice if the keyboard settings in LM17 would allow for open-ended setting of key bindings. As it is, the drop-down radio buttons and the variety of choices are nice, but nowhere near all the possibilities I want. Also, my guess is that that program is the culprit in these xmodmap problems. I don't remember having seen those settings in previous versions of LM, and I didn't have these xmodmap reversion problems in previous versions.
Re: How to make a key remap stick through reboots?
I just had this situation again, where I hit caps lock expecting the | character, as I've set my xmodmap, only to get the caps lock effect instead. I hit caps lock again, then used my xmodmap script to change the caps lock key effect... only to discover that the caps lock was still on! Meaning that X was in caps lock mode, and there was no way for me to turn it off. I had to log off in the middle of a session with some sensitive stuff going on. Grrr! This is getting really frustrating.
I looked through my startup applications and noticed that I had the "ctrl+alt+backspace" option turned on. This works via setxkbmap, which I'd never heard of before, but which seems like a likely thing to mess with xmodmap. Is it?
Something is actively and continually disrupting my xmodmap settings. I don't know what it is, but I would really like it to stop!
I looked through my startup applications and noticed that I had the "ctrl+alt+backspace" option turned on. This works via setxkbmap, which I'd never heard of before, but which seems like a likely thing to mess with xmodmap. Is it?
Something is actively and continually disrupting my xmodmap settings. I don't know what it is, but I would really like it to stop!
Re: How to make a key remap stick through reboots?
This continues to frustrate me.
iBus, which I use to do Chinese and other input, uses a single key combination to cycle through all input engines. Although this is a poor choice, they seem unlikely to change it. Someone discovered that they could use the Keyboard Shortcuts app to set specific input engines as shortcuts. I tried this, and it worked great!
...until I discovered that the keyboard shortcuts work via xkb. Argh! Xkb plays terribly with xmodmap, and so every time I activate a keyboard shortcut for a particular engine, I am blasting my carefully cultivated xmodmap settings to smithereens. It's like there are two armies battling for control of my keyboard, neither of whom has my best interests at heart.
This is really, really frustrating. Can someone post a solution, please? Please? I need my keyboard to work!
iBus, which I use to do Chinese and other input, uses a single key combination to cycle through all input engines. Although this is a poor choice, they seem unlikely to change it. Someone discovered that they could use the Keyboard Shortcuts app to set specific input engines as shortcuts. I tried this, and it worked great!
...until I discovered that the keyboard shortcuts work via xkb. Argh! Xkb plays terribly with xmodmap, and so every time I activate a keyboard shortcut for a particular engine, I am blasting my carefully cultivated xmodmap settings to smithereens. It's like there are two armies battling for control of my keyboard, neither of whom has my best interests at heart.
This is really, really frustrating. Can someone post a solution, please? Please? I need my keyboard to work!