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 down
Decrease system volume by ~10%funckey volume up
Increase system volume by ~10%funckey volume toggle-mute
Toggle the mute volumefunckey volume mute
Mute system volumefunckey volume unmute
Un-mute system volumefunckey volume get-percent
Get the system volumefunckey volume set-percent N
Set the system volume by percent
funckey brightness down
Decrease screen brightness by ~10%funckey brightness up
Increase screen brightness by ~10%funckey brightness get-percent
Get the screen brightnessfunckey brightness set-percent N
Set the screen brightness by percentfunckey brightness status
Set 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" 2
then in the template
you can have something like:
| Screen: %mybrightness% | Vol: %myvolume%