[ Prev ] [ Index ] [ Next ]

Fn-key

Created mandag 26 december 2016


Getting the Function-key to work took a little more work than I anticipated.
Out of the box monitor-off and wifi-off worked (sort of)


I was missing keyboard/screen-backlight, audio and touchpad controls.


The wifi-off worked somewhat.
It turns off the WIFI, but is unable to re-connect when re-enabled.


All of the key-presses was registered, and produced a xf86*-multimedia output.
Well.. all except keyboard-backlight which is caused by a bug (fix below)


This article will take help combine the xf86*-multimedia key-press with a function.


Screen Backlight

# There is a bug causing FN+F5/F6 not to produce any output at all.
# This can be resolved by adding acpi_osi= as a kernel module.


# Edit /etc/default/grub and add acpi_osi= to the end of CMDLINE_LINUX_DEFAULT
# Ex.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=bfq acpi_osi="


# Generate new grub.cfg
$ grub-mkconfig -o /boot/grub/grub.cfg


# No further configuration is needed for the Screen-Backlight.


Xbindkeys

# Xbindkeys can be used to bind a key-press with a function.
# Xbindkeys reads its configuration from ~/.xbindkeysrc (Github)


# Install the Xbindkeys package
$ pacman -S xbindkeys


# To autostart Xbindkeys, add it to your xinitrc.

xbindkeys &


# To get valueable information about a key-press
$ xbindkey -k


# This will produce 3 lines. Ex.

"(Scheme function)"
m:0x0 + c:121
XF86AudioMute


# First line can be replaced with a command to run
# Second and Third line can be used as binding parameters.
# We just need one of the last two lines, and we'll be using the xf86* value.


# All of these definings will be added to our ~/.xbindkeysrc file.


Volume Controls

# Requires PulseAudio and Pulseaudio-ctl
# Toggle mute

"pulseaudio-ctl mute"
	XF86AudioMute


# Volume Up

"pulseaudio-ctl up"
	XF86AudioRaiseVolume


# Volume Down

"pulseaudio-ctl down"
	XF86AudioLowerVolume


Keyboard Backlight

# We wont get the full experience with 3 steps backlight strenght - rather a 1 setting on/off
# This is still preferable from the lousy asus-kbd-backlight package from AUR, which works for 5 min.
# Install the upower package (used by all major DE basically)
$ pacman -S upower


# Add these two snippets to the ~/.xbindkeysrc

"dbus-send --type=method_call --print-reply=literal --system --dest="org.freedesktop.UPower" /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:2"
	XF86KbdBrightnessUp

"dbus-send --type=method_call --print-reply=literal --system --dest="org.freedesktop.UPower" /org/freedesktop/UPower/KbdBacklight org.freedesktop.UPower.KbdBacklight.SetBrightness int32:0"
	XF86KbdBrightnessDown


Toggle Touchpad

# Touchpad Toggle script is found at Github.
# My location for this script would be ~/.dotfiles/.scripts/toggle_touchpad.sh
# Link to that script in the ~/.xbindkeysrc file.

	"~/dotfiles/scripts/toggle_touchpad.sh"
		XF86TouchpadToggle