The officially official Devuan Forum!

You are not logged in.

#1 2017-01-18 18:13:48

Registered: 2016-12-01
Posts: 339  

How to make the 'sleep' button work if yours doesn't

How to make the 'sleep' button work if yours doesn't

One small issue that I'd been having with Devuan Jessie since I first started using it last October was that the sleep button didn't do anything. The sleep button works fine in Debian Jessie, and I suspect that upower now expects some systemd component or other. BTW, this is an ancient (2008) Compaq Presario, Dual Pentium @ 2 GHz, 4 GB RAM rig. It runs beautifully.

Typing 'sudo pm-suspend' in a terminal worked fine, so I knew that the basic sleep functionality was there. At the suggestion of ralph.ronnquist in the Hardware and System Configuration forum I decided to see if I could come up with an acpi event handler to invoke a script to run pm-suspend.

First I wanted to confirm that the sleep button was indeed generating an acpi event, so I ran acpi_listen and pressed the sleep button. Sure enough, it showed 'button/sleep SBTN 00000080 00000000 K'.

Then I went to /etc/acpi/events to make a handler for this event. There was one there already for the power button (powerbtn-acpi-support), so I just copied and modified it for my sleep button, cleverly named 'sleepbtn-acpi-support', containing the following:

event=button[ /]sleep

Then I simply made the script in /etc/acpi, to whit:


# This script calls pm-suspend when the sleep button has been
# pressed.

	# Normal handling.

That's it. Reboot, or restart the acpi daemon, and voila! A press of the sleep button now sends my computer to sleep! I had the same issue with Devuan Ascii, and the same fix applies.

Of course, now you know how to make the sleep button do whatever you want ;-)


#2 2017-01-23 20:38:03

From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,173  

Re: How to make the 'sleep' button work if yours doesn't

It's worth to note that some buttons generate many events, with different arguments. E.g., my lid button has "open" or "close" as (third) arguments . The script (or the recognition rule) will then need to distinguish appropriately, to get the right thing done for the right event(s).


#3 2017-04-04 20:37:34

Registered: 2017-02-21
Posts: 12  

Re: How to make the 'sleep' button work if yours doesn't

A slightly more complete solution

First, I commented out /etc/acpi/events/powerbtn-acpi-support:

#event=button[ /]power

This ensures that my laptop doesn't shutdown (or do anything special) when I press on the power button by mistake (it happens...).

Then I wrote a generic handler in /etc/acpi/events/default:

action=/etc/acpi/ %e

This is going to intercept every ACPI event and call a single script with all available arguments. I do not understand the design decision behind the ACPI daemon, with this concept of event files calling scripts, that tend to be so short and to multiply, so I prefer to put all the logic in a single script. Feel free to do it your own way smile

Finally, the file where the magic happens, /etc/acpi/


# log every event in /var/log/messages (can be commented later on)
logger "ACPI event $*"

case "$1" in
        [ $2 = "SBTN" ] && pm-suspend
        [ $2 = "LID" ] && [ $3 = "close" ] && pm-suspend

The actual values on someone else's system could be different, this is why it is convenient to log everything when testing the script.

Also, you do not need to restart your acpid service, you can just reload it (though I don't know whether that makes a real difference):

 # /etc/init.d/acpid reload


Board footer