You are not logged in.

#1 2009-02-07 02:58:27

Redrazor39
Member
Registered: 2008-12-23
Posts: 108

I need help binding Fn keys with Xmonad.hs

I would like to set Fn + F2 to mute, Fn + F3 to volume down, Fn + F4 to volume up, Fn + F5 for Brightness down, Fn + F6 for Brightness up, Fn +F12 to run sudo pm-suspend, in xmonad (preferably with xmonad.hs).

I do have sound working, but no way to adjust it via keyboard (which I would like to do).

After some googling and scouring through xmonad documentation, I found something that looks like it would work, but I don't completely understand it and don't know where else to look for help. Here is what someone added to their xmonad.hs file after the keybindings part:

   -- multimedia keys
   --
   -- XF86AudioLowerVolume
   , ((0            , 0x1008ff11), spawn "aumix -v -2")
   -- XF86AudioRaiseVolume
   , ((0            , 0x1008ff13), spawn "aumix -v +2")
   -- XF86AudioMute
   , ((0            , 0x1008ff12), spawn "amixer -q set PCM toggle")

The confusing part for me is the stuff like "((0            , 0x1008ff12)", which I don't understand in the slightest. Could someone please explain this to me or adjust it to mean the keybindings in the beginning of this post I want? If there is a way to just tell which keycodes should perform which functions, that would work best for me as I have my keycodes at the bottom of this post.

Also, the last part (muting) says "amixer -q set PCM toggle", when my volume is set by the Master one. Would I just have to change "PCM" to "Master" to fix that?

Btw, here's my current xmonad.hs:

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

myManageHook = composeAll
    [ className =? "Gimp"      --> doFloat
    ]

main = do
    xmproc <- spawnPipe "xmobar"
    -- make sure to edit paths to xmobar and .xmobarrc to match your system.
    -- If xmobar is in your $PATH, with config ~/.xmobarrc you don't need the
    -- xmobar path or config file, use: xmproc <- spawnPipe "xmobar"  
    xmonad $ defaultConfig
        { manageHook = manageDocks <+> manageHook defaultConfig
        , layoutHook = avoidStruts  $  layoutHook defaultConfig
        , logHook = dynamicLogWithPP $ xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50
                        }
        , modMask = mod1Mask     
    , terminal = "Terminal"
        } `additionalKeys`
        [ ((mod1Mask .|. controlMask, xK_End), spawn "sudo shutdown -h now")
        , ((controlMask, xK_Print), spawn "scrot -s")
        , ((0, xK_Print), spawn "scrot")
        ]

If it helps, here are some of my keycodes I got from xev (s1 and s2 are special buttons on my laptop, Mouse Search button is just a button on my mouse originally intended to bring up Windows search, although I don't mind using it for something else):

s1 = keycode 159
s2 = keycode 151
XF86AudioMute = keycode 160
XF86AudioLowerVolume = keycode 174
XF86AudioRaiseVolume = keycode 176
Brightness Down = keycode 101
Brightness Up = keycode 212
Mouse Search Button = keycode 229
Sleep (Fn + F12) = keycode 165

Last edited by Redrazor39 (2009-02-07 02:59:34)

Offline

#2 2009-02-08 21:07:45

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: I need help binding Fn keys with Xmonad.hs

Those numbers are the 32 bit unsigned integers that have those specific keysyms (like XF86AudioMute ...)

You should be able to get those constants symbolically from this module http://hackage.haskell.org/packages/arc … -XF86.html

(It should already be installed, given that haskell-x11-1.4.5 is in community.)

EDIT: why the cross-posting: http://bbs.archlinux.org/viewtopic.php?id=64822

That just confuses everybody

Last edited by vogt (2009-02-08 21:10:00)

Offline

Board footer

Powered by FluxBB