You are not logged in.
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
~/.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
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
Put your startup commands in .xprofile, not .xinitrc, for GDM to use them.
Last edited by rkwurth (2012-11-01 14:41:10)
Offline
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
It doesn't have to, but most people just don't set it up.
Offline
'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
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
Can we see your ~/.xprofile?
Offline
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
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
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
@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
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
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
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
@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
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
It’s finally working Thank you for providing the solution, @rkwurth.
Offline
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
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-propertiesEDIT: 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
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
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
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
#!/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