Running dwm, i needed a piece of code for the management of fn-keys. So i ended with a client/daemon application capable of doing stuff such as disabling wifi, toggle the lvds backlight, increase/decrease volume ecc ecc. The communication method is always the same: a shared fifo placed in /tmp.
Because of the need of running commands with root privileges, i added a small c launcher (hotkeys_launcher), which makes use of the ’s’ bit for invoking the daemon as super-user.
In order to use the scripts you need these programs: xrandr, amixer, xbacklight, system_info (previous post), osdc/osdd (previous post), hibernate, hibernate-ram.
Just for taste, here is the help message displayed with the client-side app:
usage: hotkeysc [option]
option:
B+ increase brightness
B- decrease brightness
Bt turn off/on brightness
G change cpu governor
H hybernate
h print this message
I displays general informations (cpu-load, temperature..)
M switch to external monitor
R restart the daemon
S suspend
Td disable trackpad
Te enable trackpad
V+ increase volume level
V- decrease volume level
Wt enable/disable wifi interface
Before using the launcher inside your .xinitrc file, try the daemon in a shell in order to debug errors due to programs not found ecc ecc.
Here is my .xbindkeysrc file configured for hotkeysc/d:
# Brightness Up
"hotkeysc B+"
m:0x0 + c:233
XF86MonBrightnessUp
# Brightness Down
"hotkeysc B-"
m:0x0 + c:232
XF86MonBrightnessDown
# Brightness Toggle
"hotkeysc Bt"
m:0x0 + c:156
XF86Launch1
# Governor
(xbindkey "hotkeysc G")
m:0x0 + c:210
XF86Launch3
# Info
(xbindkey "hotkeysc I")
m:0x0 + c:244
NoSymbol
# Monitor switch
(xbindkey "hotkeysc M")
m:0x0 + c:235
XF86Display
#--------------------------------------------------
# # Suspend
# (xbindkey "hotkeysc S")
# m:0x0 + c:223
#--------------------------------------------------
# Trackpad toggle
xbindkey "hotkeysc Tt")
m:0x0 + c:200
NoSymbol
# Volume Up
"hotkeysc V+"
m:0x0 + c:123
XF86AudioRaiseVolume
# Volume Down
"hotkeysc V-"
m:0x0 + c:122
XF86AudioLowerVolume
# Volume Toggle
"hotkeysc Vt"
m:0x0 + c:121
XF86AudioMute
# Wifi toggle
(xbindkey "hotkeysc Wt")
m:0x0 + c:246
NoSymbol
You can grab the source from the repository under the project name hotkeysd.