How to customize the zzz script for Void Linux


(last time edited: 2021-02-12)

tags: linux, void

zzz is a simple script to suspend or hibernate your system. It supports hooks before and after suspending.

First take a look at the /etc/zzz.d directory.

$ ls /etc/zzz.d

We will find 2 directories: resume and suspend.

Scripts inside the suspend directory will be executed when we run zzz. And any script file we save in the resume directory will be executed by root when the system wakes up.

In my personal system I've created 2 scripts.

This is an example of /etc/zzz.d/resume/ It executes slock when the system is woke up.


This is an example of /etc/zzz.d/suspend/


for DEVICE in  $(cut -f 1 /proc/acpi/wakeup); do
    if [ "$(grep "$DEVICE" /proc/acpi/wakeup | grep -o enabled)" = enabled ]; then
        echo "$DEVICE" > /proc/acpi/wakeup

echo "SLPB" > /proc/acpi/wakeup
echo "EXPB" > /proc/acpi/wakeup

This script disables every device that could wake up the system and only enables the Sleep and Power Button to wake it up.

If you wanna go deeper and want to understand what we are trying to do with the script you gotta understand first how /proc/acpi/wakeup works.

Try the next command:

$ cat /proc/acpi/wakeup

It shoud look something like this.

Device   S-state  Status      Sysfs node
LID       S4      *disabled   platform:PNP0C0D:00
SLPB      S3      *enabled    platform:PNP0C0E:00
IGBE      S4      *enabled
PXSX      S4      *disabled
PXSX      S4      *disabled
PXSX      S4      *disabled
PXSX      S4      *disabled
PXSX      S4      *disabled
PXSX      S4      *disabled
EXPB      S4      *enabled    pci:0000:00:1d.2
PXSX      S4      *disabled   pci:0000:03:00.0
PXSX      S4      *disabled
XHCI      S3      *enabled    pci:0000:00:14.0

Enabled devices CAN wake up the system when the it's sleeping. Disabled devices CANNOT.

Devices have their own 4 letter identification.

SLPB is for Sleep Button, EXPB is probably for External Power Button, XHCI is for xHCI USB Controllers (USB ports basically).

If you want to check which identification represent each device you can do it using lspci and grepping half of their sysfs node.

$ lspci | grep 00:14.0

You should get something like this:

00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)

Scripts must have execution permission otherwise root could not be able to run them.

# chmod +x /etc/zzz.d/suspend/ /etc/zzz.d/resume/

Happy hacking!