View Full Version : Fn key combinations for keyboard shortcuts in CCSM
rhinosaur6
November 4th, 2007, 03:08 AM
I've been unable to get the Fn key on my keyboard to be usable for shortcuts in CCSM.
When I submitted this as a bug, someone replied that based on this line in the xev output for Fn + F4
> keycode 130 (keysym 0x0, NoSymbol)
I need to have "xserver symbols" to make it work. I've been digging around on Google and checking forums, and haven't been able to turn up any explanation of what that means. I'm still very much new to Linux.
Could someone point me in the right direction?
Thank you.
Deciare
November 4th, 2007, 03:27 AM
You need to assign a key symbol to your Fn key in order for it to be recognised as a valid key press by the X server. There's probably more than one way to do this, but I'll describe the method I used to make the extra keys on my keyboard recognised.
First, you'll need to dump your current key symbol table into a file. You can do so by running this command on a console:
xmodmap -pke >~/.Xmodmap
Once the key table is dumped, open up the file ~/.Xmodmap in a text editor and look for a line that begins with "keycode 130" (your Fn key, as per xev's output). There's nothing to the right of the = sign, meaning that keycode 130 currently translates to nothing. You need to assign it a key symbol in order for it to be recognised. A list of key symbols is available in /usr/include/X11/keysymdef.h, and a list of modifiers begins with the definition of XK_Shift_L within that file. For the sake of simplicity, let's try mapping your Fn key to Hyper_L. Edit the line you found earlier to say:
keycode 130 = Hyper_L
If a different keycode is already using Hyper_L, you'll have to delete it from that other keycode, too. Save the file after you've made the changes you need.
Next, you need to load the key table you just saved. You can do so with this command:
xmodmap ~/.Xmodmap
You can put that command into your ~/.bashrc file to auto-run it when you log in:
# Only run xmodmap if logging into an X session
if [ ! -z "$DISPLAY" ]; then
# Don't run xmodmap in VNC, it breaks the keymap.
xvendor=`xdpyinfo | head -n3 | tail -n1 | cut -d: -f2`
if [ "$xvendor" != " AT&T Laboratories Cambridge" ]; then
xmodmap $HOME/.Xmodmap
fi
fi
Open xev and test whether your Fn key is now recognised as Hyper_L ("Hyper_L" should replace the part of the output that previously said "NoSymbol").
If it's recognised, you should be able to start assigning it to shortcuts in ccsm as "<Hyper>". If you're using a newer version of ccsm, this may be trickier because there's no Hyper key in its list of modifiers. ^^; I haven't thought ahead to what you'd do in that case...
rhinosaur6
November 4th, 2007, 04:35 AM
Thanks so much for your help. I was able to work forward from your suggestions to get what I needed, with some modifications.
The keycode 130 is for the combination (Fn + F4). Turns out that xev doesn't recognize (Fn) alone. By setting 130 to Hyper_L, I was setting the key combination that I wanted to use to a modifier. Since CCSM won't accept modifiers alone as key shortcuts, I had to find a non-modifier symbol to use.
F13 was available, so that's what I selected. And it works perfectly.
Unless anyone has a reason that F13 is a bad choice, I'd say we could call this thread solved.
Thanks again!
Deciare
November 4th, 2007, 08:12 AM
F13 is perfectly fine! I use F-keys, too--which can reach up to F35, by the way--for my various multimedia control keys (which I use for more interesting functions than multimedia, naturally ;)).
I initially misunderstood your question and thought you meant to assign Fn+F4 to a keyboard shortcut, but the Fn key actually changes the keycode of the key with which it is used in conjunction, so trying to make Fn work like a modifier wasn't the right approach. I get it now, though; thanks for the clarification. ^_^
Forlong
November 13th, 2007, 04:17 PM
Is it possible to map Super to Fn?
Tried doing it in .Xmodmap to no avail.
It seems to work for GNOME (but only alone) but not for Compiz at all.
Deciare
November 13th, 2007, 04:43 PM
If I understood the earlier discussion in this thread correctly, the Fn key doesn't actually generate any key code. Instead, it changes the keycode that is generated by another key when pressed together with that key. If that's true, then you wouldn't be able to map Fn to Super since Fn alone doesn't send any signal detectable by the software.
Forlong
November 13th, 2007, 07:09 PM
The weird thing is though, that the exact opposite seems to be the case. I can bind any plugin I want to Fn if I map it to F13 for example but F13+Tab is not possible.
Deciare
November 14th, 2007, 03:02 AM
Is that right? Notebook hardware is more interesting than I had anticipated.
Have you already tried binding your Fn key to Super? Instead of assigning it to F13, you'd assign it to Super_L.
Forlong
November 15th, 2007, 08:00 PM
Have you already tried binding your Fn key to Super? Instead of assigning it to F13, you'd assign it to Super_L.
Yeah, that was what I tried first but then it wasn't recognized by ccsm at all (worked in GNOME shortcuts though - but again: only alone)
psyopper
November 22nd, 2007, 09:12 PM
This is an interesting idea, I like it a lot!
I too have Zoom keys (that I'd like to bind to eZoom) but I can't seem to get them to register. Dmesg doesn't show a darned thing about key presses when I hit them. The keyboard is a Microsoft Natural Ergonomic 4000.
Any ideas on identifying the keys?
Edit: Nevermind, it looks like I'll have to futz with the kernel ("http://ubuntuforums.org/showthread.php?t=229559) to get them to work
stinkinrich88
June 20th, 2008, 09:18 PM
Hello,
I've followed the steps perfectly, assigned F20 to my play/pause button. It works fine in compiz, however, when I restart my pc it no longer works. After the reboot, xev still says play/pause is F20 and compiz still says F20 is the trigger for the command, but it won't work again until I open the key capture thing and re-assign F20 (I think I also need to run xev before this otherwise F20 is not detected at all but I can check this if you want)
any ideas?
Thanks!
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.