You are not logged in.

#1 2012-11-01 12:10:49

Lars
Member
From: /etc/shadow
Registered: 2011-10-25
Posts: 3

[SOLVED] Remap Super key to the right Control key.

I'm a GNOME user and I want to use my right Control key as a Super key. I tried to use .Xmodmap file along with the xorg-xmodmap package but it seems that the configuration is not loaded during startup (even if I add it to the .xinitrc file). However, it works correctly if I run it manually. I also searched the /usr/share/X11/xkb/rules/evdev.lst for the option I want but it wasn’t there. How am I supposed to remap this key?

Last edited by Lars (2012-11-01 23:20:15)

Offline

#2 2012-11-01 14:18:20

techryda
Member
Registered: 2012-10-01
Posts: 50

Re: [SOLVED] Remap Super key to the right Control key.

~/.xinitrc is only run if you launch X from a terminal.  If you're using systemd w/gdm it'll never be run.

Try ~/.bashrc

Last edited by techryda (2012-11-01 14:21:50)

Offline

#3 2012-11-01 14:26:25

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Remap Super key to the right Control key.

As techryda said, you are putting it in the wrong place if you are a hardcore gnome user (ie. gnome w/ gdm and all the fixin's).  Isn't there an autostart something or another within gnome?  I would imagine that could easily be used to run xmodmap.  Be advised that I have seen numerous reports of people putting xmodmap in their .xinitrc, and for some reason it doesn't run properly unless they have it sleep for a couple seconds.  So if it isn't working in the autostart thing, maybe try having it sleep a sec or three before running. 

You could definitely put it in your .bashrc as well, like techryda said, but I am not sure at what point that is sourced... and then it would be run even when you were in a tty, which is no the proper environment to be running xmodmap.

Offline

#4 2012-11-01 14:38:08

rkwurth
Member
Registered: 2012-10-31
Posts: 18

Re: [SOLVED] Remap Super key to the right Control key.

Put your startup commands in .xprofile, not .xinitrc, for GDM to use them.

Last edited by rkwurth (2012-11-01 14:41:10)

Offline

#5 2012-11-01 14:43:32

techryda
Member
Registered: 2012-10-01
Posts: 50

Re: [SOLVED] Remap Super key to the right Control key.

I stand corrected, it looks like ~/.xsession sources .xinitrc from gdm

~/.xsession

#!/bin/sh

#
# ~/.xsession
#
# Executed by xdm/gdm/kdm at login
#

/bin/bash --login -i ~/.xinitrc

Offline

#6 2012-11-01 14:44:31

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Remap Super key to the right Control key.

It doesn't have to, but most people just don't set it up.

Offline

#7 2012-11-01 14:52:13

techryda
Member
Registered: 2012-10-01
Posts: 50

Re: [SOLVED] Remap Super key to the right Control key.

'xorg-xinit' puts a default copy in '/etc/skel'.  So if 'xorg-xinit' was installed prior to a user being created then it'll be in $home.

Otherwise just copy it over.

Offline

#8 2012-11-01 15:47:39

Lars
Member
From: /etc/shadow
Registered: 2011-10-25
Posts: 3

Re: [SOLVED] Remap Super key to the right Control key.

It seems that the GDM is, for some reason, ignoring each of these files (.xinitrc, .xsession, .xprofile and .bashrc.) I also installed the xorg-xinit package which I don’t have installed before but remapping still doesn’t work on startup. Here is my .Xmodmap file:

remove Control = Control_R
keycode 105 = Super_L

As I said before, it works when it’s manually executed with “xmodmap .Xmodmap.” The different issue I can observe is that the new key binding is being reset when I switch between TTYs and then back to the first one.

Last edited by Lars (2012-11-01 15:48:24)

Offline

#9 2012-11-01 15:58:12

rkwurth
Member
Registered: 2012-10-31
Posts: 18

Re: [SOLVED] Remap Super key to the right Control key.

Can we see your ~/.xprofile?

Offline

#10 2012-11-01 16:10:08

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Remap Super key to the right Control key.

Are you sure that GDM does not use the /etc/X11/sessions directory?  I do recall reading somewhere that some dispaly managers use this instead of the traditional xinitrc or xsession.

Edit: Okay, sorry I just looked at the wiki, and apparently I am just making pointless noise here.  Sorry.   I should probably just stay out of this, as I do not even use a display manager.  I just have my window manager and X setup to run as a systemd service.

Last edited by WonderWoofy (2012-11-01 16:15:08)

Offline

#11 2012-11-01 16:44:59

rkwurth
Member
Registered: 2012-10-31
Posts: 18

Re: [SOLVED] Remap Super key to the right Control key.

I got it working here: "Alt-F2  gnome-session-properties"  opens Startup Application Preferences. Add a startup program containing

/usr/bin/xmodmap /home/your_username/.Xmodmap

systemctl restart gdm, and you should be all set.

EDIT: This doesn't survive reboot, have to manually restart gdm.

Last edited by rkwurth (2012-11-01 16:59:46)

Offline

#12 2012-11-01 17:59:16

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Remap Super key to the right Control key.

rkwurth wrote:

I got it working here: "Alt-F2  gnome-session-properties"  opens Startup Application Preferences. Add a startup program containing

/usr/bin/xmodmap /home/your_username/.Xmodmap

systemctl restart gdm, and you should be all set.

EDIT: This doesn't survive reboot, have to manually restart gdm.

This is waht I was trying to tell you earlier in the thread about the autostart thing.  I am not sure what you mean by it not surviving reboot.  Startup applications are not volatile.  I am also not sure how "This does not survive reboot..." relates at all to "... have to manually restart gdm."  What does this mean?

Offline

#13 2012-11-01 18:07:55

rkwurth
Member
Registered: 2012-10-31
Posts: 18

Re: [SOLVED] Remap Super key to the right Control key.

@WonderWoofy: Your were right about using the autostart thing.

gnome-session-properties executes my script only after I restart gdm- not when the system boots. So, after booting, I have to restart gdm for my script to be read.

Offline

#14 2012-11-01 18:11:45

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Remap Super key to the right Control key.

That is really funky... How about in the autostart command, you put a "sleep 7 &&" in front of it.  Or create a script that calls

sleep 7 && /usr/bin/xmodmap /home/$USER/.Xmodmap 

I seem to remember my trials of gnome shell resulted in something similar. and having to prepend the sleep command to a coupel different things.  I am not 100% certain that this is one of them, but it seems familiar somehow.

Last edited by WonderWoofy (2012-11-01 18:12:43)

Offline

#15 2012-11-01 19:43:44

jorges
Member
Registered: 2011-04-07
Posts: 29

Re: [SOLVED] Remap Super key to the right Control key.

Hi, I found this thread as I have a problem simmilar to the OP, I want to remap a couple of keys (Menu to backslash, and Left win to Escape). I can't get the last solution to work, though. @rkwurth: What version of gnome are you using? This is driving me crazy! I shouldn't have to spend hours on something like this!

Jorge

Edit: Well, it seems restarting gdm wasn't enough. I just rebooted and it seems to work now. Thanks for the solution

Last edited by jorges (2012-11-01 19:57:20)

Offline

#16 2012-11-01 20:39:37

rkwurth
Member
Registered: 2012-10-31
Posts: 18

Re: [SOLVED] Remap Super key to the right Control key.

Jorges- So it's working for you? I'm using 3.6, and the only way I can get it to work is by restarting gdm after booting. Just to confirm, the only thing you've done is put an entry in gnome-session-properties telling your system to execute xmodmap ~/.Xmodmap, right?

WonderWoofy- I remember seeing something similar as well, but on my system, adding the sleep command seems to prevent it from working at all, even after restarting gdm.

Offline

#17 2012-11-01 21:16:31

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Remap Super key to the right Control key.

@rkwurth, what if you use the second part of my recommendation and make a script that executes sleep then xmodmap?  I think that maybe the gnome autostart does not recognize the &&.  If you do try the script, don't forget to make it executable.

Offline

#18 2012-11-01 21:50:59

rkwurth
Member
Registered: 2012-10-31
Posts: 18

Re: [SOLVED] Remap Super key to the right Control key.

Hey, that seems to have done the trick! Thank you.

To recap, in order to remap keys using xmodmap in gnome 3.6/gdm, we:
1. define our adjustment(s) in ~/.Xmodmap
2. create an executable script containing "sleep 7 && /usr/bin/xmodmap /home/$USER/.Xmodmap"
3. call that script using gnome-session-properties

EDIT: Upon returning from suspend, the xmodmap modifications are lost.

Last edited by rkwurth (2012-11-01 23:20:26)

Offline

#19 2012-11-01 23:19:56

Lars
Member
From: /etc/shadow
Registered: 2011-10-25
Posts: 3

Re: [SOLVED] Remap Super key to the right Control key.

It’s finally working smile Thank you for providing the solution, @rkwurth.

Offline

#20 2012-11-01 23:23:24

rkwurth
Member
Registered: 2012-10-31
Posts: 18

Re: [SOLVED] Remap Super key to the right Control key.

You're welcome, and thank you WonderWoofy too!

Lars, do your modifications persist after suspend, or is that just an issue I'm experiencing?

Offline

#21 2012-11-02 01:58:37

jorges
Member
Registered: 2011-04-07
Posts: 29

Re: [SOLVED] Remap Super key to the right Control key.

rkwurth wrote:

Hey, that seems to have done the trick! Thank you.

To recap, in order to remap keys using xmodmap in gnome 3.6/gdm, we:
1. define our adjustment(s) in ~/.Xmodmap
2. create an executable script containing "sleep 7 && /usr/bin/xmodmap /home/$USER/.Xmodmap"
3. call that script using gnome-session-properties

EDIT: Upon returning from suspend, the xmodmap modifications are lost.

Sorry to answer just now, I've been away from my laptop. I did almost that, but my script just have those commands in separate lines, which I believe has a slightly different meaning in bash. I also loose the modifications after resuming from suspend.

Offline

#22 2012-11-02 02:06:23

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Remap Super key to the right Control key.

To reenable the modifications after suspend, you may do some of two things.  You can either learn how to write a service file, and have it Wants=suspend.target as well as After=suspend.target, or you can use /usr/lib/systemd/system-sleep.  This directory, any script that resides there will be run before and after suspend or hibernate.  It will be given the flags pre or post and suspend or hibernate.  Its pretty simple.

Edit: Okay, I thought about it, and I'll just give this to you

#!/bin/bash
[[ $1 == 'post' ]] && /usr/bin/xmodmap /home/$USER/.Xmodmap 

Last edited by WonderWoofy (2012-11-02 02:10:41)

Offline

#23 2012-11-03 05:06:24

jorges
Member
Registered: 2011-04-07
Posts: 29

Re: [SOLVED] Remap Super key to the right Control key.

WonderWoofy wrote:

To reenable the modifications after suspend, you may do some of two things.  You can either learn how to write a service file, and have it Wants=suspend.target as well as After=suspend.target, or you can use /usr/lib/systemd/system-sleep.  This directory, any script that resides there will be run before and after suspend or hibernate.  It will be given the flags pre or post and suspend or hibernate.  Its pretty simple.

Edit: Okay, I thought about it, and I'll just give this to you

#!/bin/bash
[[ $1 == 'post' ]] && /usr/bin/xmodmap /home/$USER/.Xmodmap 

Thanks for the info, but there's a problem with your suggestion:

$ journalctl -b -u systemd-suspend
<snip>
Nov 03 01:39:51 acero systemd-sleep[1943]: /usr/bin/xmodmap:  unable to open    display ''

Does it means systemd executes the script as another user?

Offline

#24 2012-11-07 06:33:10

rahul
Member
Registered: 2012-10-14
Posts: 1

Re: [SOLVED] Remap Super key to the right Control key.

jorges wrote:

Does it means systemd executes the script as another user?

i believe it executes as root, so it should work if you `su` to jorges:

#!/bin/bash

if [ "$1" = "post" ] ; then
    typeset -x DISPLAY=:0.0
    # sleep 1
    su -c "/usr/bin/xmodmap ~/.Xmodmap" jorges
fi

the `sleep` part might be needed depending on your setup.

Offline

#25 2012-11-07 13:34:34

jorges
Member
Registered: 2011-04-07
Posts: 29

Re: [SOLVED] Remap Super key to the right Control key.

rahul wrote:
#!/bin/bash

if [ "$1" = "post" ] ; then
    typeset -x DISPLAY=:0.0
    # sleep 1
    su -c "/usr/bin/xmodmap ~/.Xmodmap" jorges
fi

the `sleep` part might be needed depending on your setup.

Thanks, it works now. It might no be a general solution, but at least I don't have to manually run xmodmap after every resume from suspend.

jorges

Offline

Board footer

Powered by FluxBB