Some time ago, a colleague asked me about xmonad configuration of special key handlers when he noticed I’m xmonad user as well. He was interested in as simple as possible xmonad config file which defines actions for for volume and brightness control keys found on all recent laptops.
So let’s see the minimal example of such configuration I come up with (on
Fedora 33 machine with
import Graphics.X11.ExtraTypes.XF86 import XMonad import XMonad.Config import XMonad.Util.EZConfig = [ myKeys 0, xF86XK_AudioRaiseVolume), spawn "amixer -D pulse sset Master 10%+") ((0, xF86XK_AudioLowerVolume), spawn "amixer -D pulse sset Master 10%-") , ((0, xF86XK_AudioMute), spawn "amixer -D pulse sset Master toggle") , ((0, xF86XK_AudioMicMute), spawn "amixer -D pulse sset Capture toggle") , ((0, xF86XK_MonBrightnessUp), spawn "brightnessctl set +10%") , ((0, xF86XK_MonBrightnessDown), spawn "brightnessctl set 10%-") , (( ] = xmonad $ def `additionalKeys` myKeysmain
First of all we need to import
module, which defines
KeySym constants like
xF86XK_AudioRaiseVolume we want
to use in our definition of key shortcuts.
Then we create
myKeys list with definitions of key shortcut actions as
additionalKeys function from
module. As you can see, each key listed there starts a subprocess with given
And finally, we add
myKeys configuration on top of default xmonad
additionalKeys function, and pass the result
If you want to build your own configuration on top of this example, I suggest
to start with xmonad page on archlinux
introduction there is very nice, references upstream haskell
wiki when necessary and I just
added a note about
Graphics.X11.ExtraTypes.XF86 module with a simple
similar to what is shown in this post.