Trying to understand what's happenning
If I type xmodmap
without argument (to get modifier list), I get:
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25)
mod1 Alt_L (0x40), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3 ISO_Level5_Shift (0x69)
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
The important part is for mod4
. That's where Super_L
is.
Now, I run : xmodmap -e "keycode 133 = Tab Super_L" && xmodmap | grep mod4
, and I get:
mod4 Tab (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
The mod4
line changed and added Tab
. That's why your key 133
still open the window menu.
By the way, I'm trying this on I3WM
so the results can be a bit different.
For example, if I press the key 133
on a terminal or text editor, it both write a tab and becomes a modifier.
I also noticed I don't have a different behavior with Shift
because the type of the key is ONE_LEVEL
.
You can also run xev | grep key
to see what happens with some key combinations.
Solution
But xmodmap
also tells you can't have more than 4 keys per modifier, so a solution (the only one that worked for me so far) is to sacrifice a key you don't use / don't have, make it become a Super_L
.
If you use QWERTY
, you can modify the layout located on /usr/share/X11/xkb/symbols/us
(it's usually another file of the same folder if you're using another layout), and write:
key.type[Group1] = "TWO_LEVEL";
key <MENU>{[Super_L]}; // ONE or TWO level, assuming MENU key isn't used
key <LWIN>{[ Tab, Super_L]}; // should be TWO_LEVEL
key.type[Group1] = "ONE_LEVEL";
instead of (probably line 14 of the file)
key <LWIN>{[Super_L]};
Then, update your keyboard layout with setxkbmap us && xmodmap | grep mod4
.
You will get something like:
mod4 Super_R (0x86), Super_L (0x87), Super_L (0xce), Hyper_L (0xcf)
If you still get Tab
, you should probably sacrifice another key.
Note that 0x85
is the hexadecimal value of 133
, that mean this key will not be a direct mod4
but it still can behave like window key if Shift
is pressed.
Best Answer
Sourcing commands during login
I've not tried either
.xinitrc
or.xsession
files to do this, but I have done it using a custom launcher that gets run when I login. You can access the dialog that allows you to do this a couple of ways, I usually just launch it from the command line like so.The GUI looks like this.
From here you can create your own custom startup launchers and then point them to shell scripts that contain what ever commands you need to invoke. Here I've created my own Dropbox launcher script that gets executed when I log in.
Mapping keys to run commands
If on the other hand you're looking to create shortcut key combinations that will launch commands, I've successfully been using XBindKeys on GNOME 3.8.4 for this very purpose.
My use has been modest but I like to create keyboard shortcuts for Nautilus to launch with certain directories opened.
Example
You'll need to first make sure the packages
xbindkeys
is installed.Then you'll need to run the following command, one time only, to create a template
xbindkeys
configuration file.With the file created you can open it in a text editor and add a rule like this:
With the above change made we need to kill
xbindkeys
if it's already running and then restart it.Now with this running any time I type Mod+Shift+Q Nautilus will open with the corresponding folder opened.
Why isn't .xsession or .xinit getting sourced
I believe the ultimate issue lies with this post, titled: Quickly Setting up Awesome with Gnome. It discusses methods for getting GDM (GNOME's Display Manager) into loading these files, which to me implies that it doesn't by default.
My Fedora 19 system contains this file:
/usr/share/xsessions/gnome.desktop
which contains these lines:I believe gnome-session doesn't source your
.xsession
file by default, and the.xinit
is meant to be sourced if you invoke GNOME usingstartx
.Be sure to look through the section titled: with GDM, which shows this in more details.
References