Several posts ago, I wrote up a little tutorial explaining how to stop your Asus laptop's keyboard backlight from having a seizure when putting your laptop into suspend/hibernate by adapting some scripts that someone had uploaded to a thread on ubuntuforums.com.

Well, Arch Linux has decided to move away from using initscripts and use service manager called systemd. This unexpected surprise (I should probably subscribe to the Arch mailing list) broke GDM and my Xorg server without warning and has caused me several inconveniences today that I've had to fix, with this being most involved and irritating issue. Let me explain below.

By default, systemd handles certain ACPI events -- namely suspend and hibernate. This breaks the aforementioned script because we have a custom pm-utils hook in /etc/pm/sleep.d that starts the magic. While it looks like you can disable systemd from handling ACPI events and let the window manager do everything (AKA, call pm-utils), I wasn't able to make this work. No matter what I did, systemd kept suspending my laptop instead of pm-utils and my keyboard would seizure every time I put my laptop to sleep.

Luckily, systemd has a similar custom hook setup documented on the Arch wiki, so with all of the acpi scripts in /etc/acpi, I created a systemd sleep hook that will work the same as the pm-utils sleep hook. To use it, download it into /usr/lib/systemd/system-sleep/ and mark it as executable. For convenience, the source is below.

#!/bin/bash

############################################
# File: asus-keyboard-backlight.sh
#
# Author: Chris Olin (https://www.chrisolin.com)
#
# Date: Sun 04 Nov 2012 10:32:58 PM EST
#
# Purpose: Dim Asus keyboard backlight
#          prior to hibernate/suspend
#          and restore backlight on resume
############################################

BRIGHTNESSFILE=/tmp/kbd-brightness

if [[ $1 == 'pre' ]] ; then
    STATUS="`cat /sys/devices/platform/asus_laptop/leds/asus::kbd_backlight/brightness`"
    STATUS=$(($STATUS-128))
    echo $STATUS > $BRIGHTNESSFILE
    for i in `seq 0 $STATUS`; do
	    /etc/acpi/asus-kb-brightness-down.sh
    done
elif [[ $1 == 'post' ]] ; then
    	if [ -f $BRIGHTNESSFILE ]; then
        	STATUS=`cat $BRIGHTNESSFILE`
   	 else
        	STATUS=2
	fi
	for i in `seq 0 $STATUS` ; do
		/etc/acpi/asus-kb-brightness-up.sh
	done
fi

I've also taken the original archive and modified it to include this script and have the install script place it in the proper directory. Going one more step further, I created a Github repository out of habit in case I have to update this in the future. Note that the ACPI python scripts were not created by me and I don't know who the original author is.

Lastly, I noticed that the ACPI event for the backlight keys changed from ATKD from ATK0100:00 (which you can see by using the command after pressing the relevant hotkey:

# tail -f /var/log/messages.log

I've edited the event files to reflect this so the keyboard brightness hotkeys will continue to work.