funckey is a simple go cli program that wraps lower level linux cli apps that are commonly mapped to function keys on laptops.
I made this so I could easily map my volume and brightness function keys on my laptop to work when running xmonad and xmobar (see config examples below). If you're using gnome/kde you probably don't need something like this.
go get github.com/jacktasia/funckey
then
go install github.com/jacktasia/funckey
Ensure you have pactl installed
and
that the /sys/class/backlight/intel_backlight/brightness file exists.
By default the brightness file is owned by root.
Your user needs to be able to edit the brightness file, change jack to your username:
sudo chown jack:jack /sys/class/backlight/intel_backlight/brightness
This will change the permissions for just this boot. To change the permissions going forward do this:
sudo nano /etc/udev/rules.d/90-myrules.rules and add a line with:
Again, make sure you update your username here (replace jack) too.
KERNEL=="intel_backlight", SUBSYSTEM=="backlight", RUN+="/usr/bin/find /sys/class/backlight/intel_backlight/ -type f -name brightness -exec chown jack:jack {} ; -exec chmod 666 {} ;"
funckey volume downDecrease system volume by ~10%funckey volume upIncrease system volume by ~10%funckey volume toggle-muteToggle the mute volumefunckey volume muteMute system volumefunckey volume unmuteUn-mute system volumefunckey volume get-percentGet the system volumefunckey volume set-percent NSet the system volume by percent
funckey brightness downDecrease screen brightness by ~10%funckey brightness upIncrease screen brightness by ~10%funckey brightness get-percentGet the screen brightnessfunckey brightness set-percent NSet the screen brightness by percentfunckey brightness statusSet the screen brightness status
A snippet of my xmonad.hs config using import XMonad.Util.EZConfig:
("<XF86MonBrightnessDown>", spawn "funckey brightness down"),
("<XF86MonBrightnessUp>", spawn "funckey brightness up"),
("<XF86AudioLowerVolume>", spawn "funckey volume down"),
("<XF86AudioRaiseVolume>", spawn "funckey volume up"),
("<XF86AudioMute>", spawn "funckey volume toggle-mute")In the commands section of the config:
, Run Com "funckey" ["brightness", "get-percent"] "mybrightness" 2
, Run Com "funckey" ["volume", "get-percent"] "myvolume" 2then in the template you can have something like:
| Screen: %mybrightness% | Vol: %myvolume%