Loading...


bookmark - Hotkeys / Keyboard Quick Launch Keys In Linux

Hotkeys / Keyboard Quick Launch Keys In Linux

 
 Discussion by intrepid with 6 Replies.
 Last Update: December 3, 2009, 11:07 am
 
bookmark - Hotkeys / Keyboard Quick Launch Keys In Linux  
Quickly Post to Hotkeys / Keyboard Quick Launch Keys In Linux  w/o signup Share Info about Hotkeys / Keyboard Quick Launch Keys In Linux  using Facebook, Twitter etc. email your friend about Hotkeys / Keyboard Quick Launch Keys In Linux Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

I first submitted this tutorial a couple of months ago over at http://linuxiso.org/forums as user adpsimpson.

Having spent ages wishing the hotkeys on my laptop would work, I spent most of an afternoon looking into it. Since no site I found explained it satisfactorily, here's my method...

The first step is to find out which of the keys are registered by the kernel, and what their keycodes are (the unique event number that they cause). To do this you need a program called xev, (in Mandrake this is part of X11R6-contrib, is installed by default in Slack, and should be easy to find for other distros). From the terminal, in a graphical interface, type xev to launch it, move the mouse over the new window and press the hotkeys. What appears in the terminal is something like

CODE

KeyPress event, serial 28, synthetic NO, window 0x2c00001,
   root 0xb5, subw 0x2c00002, time 3593153, (55,38), root:(730,82),
   state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
   XLookupString gives 0 bytes:  ""



The "keycode" (in this case 64) is the important part. The next is to make the keycode actually do something when X registers it. For this you need to run xmodmap to modify the keyboard map. A small script in the ~/.kde/Autostart folder (or similar for other desktops) means this will be done each time KDE is stated. I wanted key 176 to increase the system volume, and 174 to decrease it, so the script reads

CODE

xmodmap -e 'keycode 174=F21' #voldown
xmodmap -e 'keycode 176=F22' #volup


Don't forget to make this executable. Run this script, re-run xev and you should now see, for example, F22 or F21 in the even notification.

The final step is to make F21 or F22 (or whatever you called your keys) actually do something useful. You can do this using the existing shortcut options (if you wish it to start an application), or you can use the program xbindkeys, here - http://hocwp.free.fr/xbindkeys/xbindkeys.html . This program links key events to bash commands, very easily.

The script in the KDE Autostart folder can then be modified to launch xbindkeys when KDE is launched, and the file ~/.xbindkeysrc modified to link the key events to the desired bash commands. I used dcop (the inter-program communication process) to tell kmix (the default KDE mixer) to increase/decrease the master volume (channel 0) whenever the relevant keys were pressed. Below is the complete file ~/.kde/Autostart/keycodes (MUST be executable):

CODE

#!/bin/sh
#file to map special keys.
#File location: ~/.kde/Autostart
#File Name:keycodes

xmodmap -e 'keycode 174=F21' #voldown
xmodmap -e 'keycode 176=F22' #volup

#Open kmix to allow xbindkeys to work:
kmix

#Open xbindkeys to link keys to applications:
xbindkeys
and the few lines I had to add to ~/.xbindkeysrc:
Code:
#Volume decrease
"dcop kmix Mixer0 decreaseVolume 0"
 F21

#Volume increase
"dcop kmix Mixer0 increaseVolume 0"
 F22



Hopefully this will help people make their keyboards more useful. If anyone has any further suggestions, or knows of obvious or important differences between desktop environments, please post them below. However it should be relatively distro/desktop independent.

   Wed Dec 15, 2004    Reply         

That's very useful.
I'll be looking back to this when I get a keyboard with hotkeys.

   Tue Dec 21, 2004    Reply         

Ugh, I hate hotkeys. I always had them disabled on my laptop, because if you'd accidentally press one, you would end up having to wait a minute (painfully slow computer) just to close whatever you opened.

   Tue Dec 28, 2004    Reply         


Good point.
That happened to me a few times at school once.
Even if your keyboard doesn't have hotkeys, the F1 (Help) button can be annoying when you're reaching for the F2 (Rename) button.

   Mon Jan 3, 2005    Reply         

Rally good, I've been looking for something like this. I hate exit from full screen mode just to increase the volume.

-reply by physlord

   Wed Apr 23, 2008    Reply         

A better hotkey system (or different at least)
Hotkeys / Keyboard Quick Launch Keys In Linux

Is it possible to listen to those keystrokes, keep them in a buffer, and setup hotkeys, then have a "fire" key that actually launches programs? Ideally then if you type in the say "ff[tab]" firefox would open, etc.



-reply by joseph

   Wed Jun 25, 2008    Reply         


KDE4 quick updateHotkeys / Keyboard Quick Launch Keys In Linux

In KDE4, at least under OpenSuSE 11.2, the directory for autostart is actually ~/.Kde4/Autostart

-reply by Jessica Tanenhaus

   Thu Dec 3, 2009    Reply         

Quickly Post to Hotkeys / Keyboard Quick Launch Keys In Linux  w/o signup Share Info about Hotkeys / Keyboard Quick Launch Keys In Linux  using Facebook, Twitter etc. email your friend about Hotkeys / Keyboard Quick Launch Keys In Linux Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Using Ntloader To Boot Linux

Basically what we're going to do with NTLoader is use NTLoader to boot into Linux's bootloader which then boots Linux, why someone would do that when Grub works perfectly fine booting Windows on NTFS? Who knows what reason other than it could destroy their MBR and make both OS inaccessible ...more

   22-Nov-2004    Reply         

I Am Planning To Use Linux What Sho...

I am planning to install linux on my pc. I have tried once but I had hard times installing. Could someone help me and suggest what should I do first? Or is there a tutorial on how can I start linux on my pc? Thanks... ...more

   17-Mar-2005    Reply         

Which Linux?

Which Linux is the best in your view? I was just woundering what linux you all like better and why even if you give me a few you like and the pros and con of each and the one you recommend for me to use. I have had a look at alot and i just cant deside on which to get. Im a ...more

   03-Apr-2005    Reply         

Using Ntloader To Boot Linux Win2K or XP, should work with most Linux   Using Ntloader To Boot Linux Win2K or XP, should work with most Linux (3) (9) Howto: Domain Name Server On Linux DNS for your Intranet (or Internet) Serv  Howto: Domain Name Server On Linux DNS for your Intranet (or Internet) Serv