How to find the XF86Launch1-Key reference?

Hi, I use a Lenovo T61 with Arch Linux and Xmonad. The Laptop has this blue "ThinkVantage" Button in the upper left corner. I'd like to use this key for toggling my CPU-Frequency. I've written a little function in Haskell being inspired by a blog entry by Don Stewart (http://cgi.cse.unsw.edu.au/~dons/blog/2007/03). A) The reference to the key The function works as it should and now I'd like to bind it in my xmonad.hs. However, I just cannot figure out how to refer to this "ThinkVantage"-Button in my xmonad.hs. I had a look at http://www.haskell.org/haskellwiki/Xmonad/Frequently_asked_questions#What_is... which tells me to have a look at: $ xev | sed -ne '/^KeyPress/,/^$/p' KeyPress event, serial 28, synthetic NO, window 0x2c00001, root 0x102, subw 0x0, time 31601784, (329,154), root:(855,155), state 0x0, keycode 156 (keysym 0x1008ff41, XF86Launch1), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False so I know now the keysym and I know its bind to XF86Launch1. But how do I find out how I can refer to this key within Xmonad? I looked into the file /usr/include/X11/keysymdef.h and searched for "ff41", "XF", "launch", etc. but no luck. Does anyone know, where to look for the right place? B) Nicer binding At the moment, I have the following: A file CpuToggle.hs, which is --- --- --- module CpuToggle (toggle) where import Text.Printf import System.Process toggle = do s <- readProcess "cpufreq-info" [] [] case (clean s) of True -> do system "sudo cpufreq-set -c 0 -f 2500000" system "sudo cpufreq-set -c 1 -f 2500000" printf "CPU is toggled up.\n" False -> do system "sudo cpufreq-set -c 0 -f 1200000" system "sudo cpufreq-set -c 1 -f 1200000" printf "CPU is toggled down.\n" clean :: String -> Bool clean cs = let a = read $ (!! 4) . words . (!! 11) . lines $ cs b = read $ (!! 4) . words . (!! 21) . lines $ cs in (a < 2.5 || b < 2.5) --- --- --- and a file toggle.hs, which is: --- --- --- import CpuToggle main = toggle --- --- --- the latter I compile and put something like , ((modm, xK_F11), spawn "/home/thomas/toggle") into my xmonad.hs. Works just fine!! Now, well, I just *really* would like to write someting like import CupToggle ... , ((modm, xK_F11), toggle) instead. How would I need to change the toggle-function in the CpuToggle-Module in order to achieve this? Thanks so much!! Cheers, Thomas

On Fri, 25 Sep 2009 16:28:06 -0400
Thomas Friedrich
... KeyPress event, serial 28, synthetic NO, window 0x2c00001, root 0x102, subw 0x0, time 31601784, (329,154), root:(855,155), state 0x0, keycode 156 (keysym 0x1008ff41, XF86Launch1), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
so I know now the keysym and I know its bind to XF86Launch1. But how do I find out how I can refer to this key within Xmonad? ... Hi Thomas,
I have the follow bindings in my xmonad.hs for the multimedia keys and the ThinkVantage key(Lenovo R61): -------------------------8<------------------------------ -- multimedia keys -- XF86AudioLowerVolume , ((0 , 0x1008ff13), spawn "volume-louder") -- XF86AudioRaiseVolume , ((0 , 0x1008ff11), spawn "volume-quieter") -- XF86AudioMute , ((0 , 0x1008ff12), spawn "volume-mute") -- XF86AudioMicMute , ((0 , 0x1008ff41), spawn "volume-mic-mute") -- XF86AudioNext , ((0 , 0x1008ff17), spawn "player-next") -- XF86AudioPrev , ((0 , 0x1008ff16), spawn "player-prev") -- XF86AudioPlay , ((0 , 0x1008ff14), spawn "player-start") -- XF86AudioStop , ((0 , 0x1008ff15), spawn "player-stop") -------------------------8<------------------------------ It works fine for me, as you can see, I use "0x1008ff41" keysym directly. Cheers, Sergey

* On Friday, September 25 2009, Sergey Manucharian wrote: ...
-- XF86AudioStop , ((0 , 0x1008ff15), spawn "player-stop") -------------------------8<------------------------------
It works fine for me, as you can see, I use "0x1008ff41" keysym directly.
Here are two alternative methods of getting those keysyms:
If you have X11 > 1.4.2 which was build with the XF86keysym.h header
available, you can import Graphics.X11.ExtraTypes.XF86, and then use the
keysyms defined there:
http://hackage.haskell.org/packages/archive/X11/1.4.5/doc/html/Graphics-X11-...
If you don't have that module, can use CPP which could be preferable to
using the numeric values of the keysyms:
------------ Config Using CPP to add keysyms -------------------------
{-# LANGUAGE CPP #-}
module Main where
import XMonad
import XMonad.Util.EZConfig
#include

Quoting Sergey Manucharian
On Fri, 25 Sep 2009 16:28:06 -0400 Thomas Friedrich
wrote: so I know now the keysym and I know its bind to XF86Launch1. But how do I find out how I can refer to this key within Xmonad?
According to this page: http://hackage.haskell.org/packages/archive/X11/1.4.5/doc/html/Graphics-X11-... the constant you want for XF86Launch1 is xF86XK_Launch1 from the Graphics.X11.ExtraTypes.XF86 module.
-- multimedia keys -- XF86AudioLowerVolume , ((0 , 0x1008ff13), spawn "volume-louder") -- XF86AudioRaiseVolume , ((0 , 0x1008ff11), spawn "volume-quieter") -- XF86AudioMute , ((0 , 0x1008ff12), spawn "volume-mute") -- XF86AudioMicMute , ((0 , 0x1008ff41), spawn "volume-mic-mute") -- XF86AudioNext , ((0 , 0x1008ff17), spawn "player-next") -- XF86AudioPrev , ((0 , 0x1008ff16), spawn "player-prev") -- XF86AudioPlay , ((0 , 0x1008ff14), spawn "player-start") -- XF86AudioStop , ((0 , 0x1008ff15), spawn "player-stop")
I actually winced reading these. All these keys are defined with readable names on the page linked above. ~d

On Sun, 27 Sep 2009 02:10:40 -0400 wagnerdm@seas.upenn.edu wrote:
...
-- XF86AudioStop , ((0 , 0x1008ff15), spawn "player-stop")
I actually winced reading these. All these keys are defined with readable names on the page linked above.
Well, I did it long time ago, and I remember, that I had problems with some of ThinkPad R61 keys, especially with the ThinkVantage. That's why I've just put xev stuff in the bindings directly. Cheers, Sergey

wagnerdm@seas.upenn.edu wrote:
Quoting Sergey Manucharian
: On Fri, 25 Sep 2009 16:28:06 -0400 Thomas Friedrich
wrote: so I know now the keysym and I know its bind to XF86Launch1. But how do I find out how I can refer to this key within Xmonad?
According to this page: http://hackage.haskell.org/packages/archive/X11/1.4.5/doc/html/Graphics-X11-...
the constant you want for XF86Launch1 is xF86XK_Launch1 from the Graphics.X11.ExtraTypes.XF86 module.
Hey, thanks, that's even better. I actually prefer referring to the keysyms by readable names!! Works perfect! Cheers, Thomas

Sergey Manucharian wrote:
On Fri, 25 Sep 2009 16:28:06 -0400 Thomas Friedrich
wrote: ... KeyPress event, serial 28, synthetic NO, window 0x2c00001, root 0x102, subw 0x0, time 31601784, (329,154), root:(855,155), state 0x0, keycode 156 (keysym 0x1008ff41, XF86Launch1), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
so I know now the keysym and I know its bind to XF86Launch1. But how do I find out how I can refer to this key within Xmonad? ...
Hi Thomas,
I have the follow bindings in my xmonad.hs for the multimedia keys and the ThinkVantage key(Lenovo R61):
-------------------------8<------------------------------
-- multimedia keys -- XF86AudioLowerVolume , ((0 , 0x1008ff13), spawn "volume-louder") -- XF86AudioRaiseVolume , ((0 , 0x1008ff11), spawn "volume-quieter") -- XF86AudioMute , ((0 , 0x1008ff12), spawn "volume-mute") -- XF86AudioMicMute , ((0 , 0x1008ff41), spawn "volume-mic-mute") -- XF86AudioNext , ((0 , 0x1008ff17), spawn "player-next") -- XF86AudioPrev , ((0 , 0x1008ff16), spawn "player-prev") -- XF86AudioPlay , ((0 , 0x1008ff14), spawn "player-start") -- XF86AudioStop , ((0 , 0x1008ff15), spawn "player-stop") -------------------------8<------------------------------
It works fine for me, as you can see, I use "0x1008ff41" keysym directly.
Cheers, Sergey
Thanks so much Sergey. I didn't know you could just use the keysym directly. That's great and it works!! Thanks again, Thomas
participants (4)
-
Adam Vogt
-
Sergey Manucharian
-
Thomas Friedrich
-
wagnerdm@seas.upenn.edu