How to make a key remap stick through reboots?

How to make a key remap stick through reboots?

Postby shimi on Tue Dec 11, 2012 5:01 am

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?
shimi
Level 1
Level 1
 
Posts: 7
Joined: Fri Jun 25, 2010 4:23 am

Linux Mint is funded by ads and donations.
 

Re: How to make a key remap stick through reboots?

Postby kraasch on Fri Dec 14, 2012 1:11 pm

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
kraasch
Level 1
Level 1
 
Posts: 1
Joined: Fri Dec 14, 2012 1:03 pm

Re: How to make a key remap stick through reboots?

Postby shimi on Sat Dec 15, 2012 4:23 am

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.
shimi
Level 1
Level 1
 
Posts: 7
Joined: Fri Jun 25, 2010 4:23 am

Re: How to make a key remap stick through reboots?

Postby pmorton on Mon Dec 17, 2012 6:51 pm

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:

Code: Select all
xmodmap -e "keycode 13 = 4 sterling"


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?
pmorton
Level 1
Level 1
 
Posts: 7
Joined: Sun Jul 25, 2010 10:13 am

Re: How to make a key remap stick through reboots?

Postby pmorton on Sun Jan 13, 2013 10:45 am

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:

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"


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:

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"


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?
pmorton
Level 1
Level 1
 
Posts: 7
Joined: Sun Jul 25, 2010 10:13 am

Re: How to make a key remap stick through reboots?

Postby pmorton on Sat Jan 26, 2013 10:19 am

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:

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"


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.
pmorton
Level 1
Level 1
 
Posts: 7
Joined: Sun Jul 25, 2010 10:13 am

Re: How to make a key remap stick through reboots?

Postby sectionq on Sun Jan 27, 2013 5:59 pm

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?
sectionq
Level 1
Level 1
 
Posts: 9
Joined: Thu Jan 24, 2013 6:08 pm

Re: How to make a key remap stick through reboots?

Postby pmorton on Mon Jan 28, 2013 6:07 pm

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?
pmorton
Level 1
Level 1
 
Posts: 7
Joined: Sun Jul 25, 2010 10:13 am

Re: How to make a key remap stick through reboots?

Postby jtsang37 on Tue Jan 29, 2013 4:19 am

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

Code: Select all
/usr/bin/setxkbmap -option "ctrl:nocaps"


Hope that helps :)
jtsang37
Level 1
Level 1
 
Posts: 1
Joined: Sun Dec 16, 2012 7:37 pm

Re: How to make a key remap stick through reboots?

Postby sectionq on Wed Jan 30, 2013 11:23 am

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.
sectionq
Level 1
Level 1
 
Posts: 9
Joined: Thu Jan 24, 2013 6:08 pm

Re: How to make a key remap stick through reboots?

Postby pmorton on Wed Jan 30, 2013 5:33 pm

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?


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:

Code: Select all
sudo ln -s  /etc/apm/scripts.d/PoundNotDollar.sh    /etc/apm/resume.d/PoundNotDollar.sh


The Dollar to Pound key mapping is now functioning on power resume.
pmorton
Level 1
Level 1
 
Posts: 7
Joined: Sun Jul 25, 2010 10:13 am

Re: How to make a key remap stick through reboots?

Postby dmp1ce on Sat Feb 23, 2013 3:14 pm

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 :)
dmp1ce
Level 1
Level 1
 
Posts: 2
Joined: Sat Feb 23, 2013 2:58 pm

Re: How to make a key remap stick through reboots?

Postby dmp1ce on Sat Feb 23, 2013 5:15 pm

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.
dmp1ce
Level 1
Level 1
 
Posts: 2
Joined: Sat Feb 23, 2013 2:58 pm

Re: How to make a key remap stick through reboots?

Postby Abschiedsstein on Sat Jul 27, 2013 12:15 am

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
Abschiedsstein
Level 1
Level 1
 
Posts: 2
Joined: Sat Jul 27, 2013 12:02 am

Re: How to make a key remap stick through reboots?

Postby jhyland87 on Tue Sep 24, 2013 4:37 am

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!
jhyland87
Level 1
Level 1
 
Posts: 4
Joined: Fri Aug 20, 2010 2:16 pm

Re: How to make a key remap stick through reboots?

Postby jhyland87 on Tue Sep 24, 2013 4:40 am

jhyland87
Level 1
Level 1
 
Posts: 4
Joined: Fri Aug 20, 2010 2:16 pm

Re: How to make a key remap stick through reboots?

Postby fifthrider on Fri Jan 03, 2014 6:07 pm

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.
fifthrider
Level 1
Level 1
 
Posts: 2
Joined: Fri Jan 03, 2014 6:04 pm

Re: How to make a key remap stick through reboots?

Postby jiawen on Wed Jul 30, 2014 8:10 am

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.
New desktop: Linux Mint 14 | Mate 1.4.2 | i5 2500K CPU | 8 GB RAM | GTX 560 Ti | c. 1.6 TB HD ||| Netbook: Xubuntu 10.04 | AMD Dual-core 1.6 GHz | 2 GB RAM | 320 GB HD
jiawen
Level 1
Level 1
 
Posts: 21
Joined: Sun Mar 17, 2013 5:29 pm

Linux Mint is funded by ads and donations.
 

Return to MATE

Who is online

Users browsing this forum: No registered users and 9 guests