Home | News | Download | Packages | Forum | Wiki | Github

Do not suspend when laptop's lid is closed


Side note:

$ ls /etc/default/grub*
/etc/default/grub /etc/default/grub.new-2.02~beta3_3

conf files that are modified have suffixed new versions installed, plus a message is shown during updates (when done via the terminal, not sure about with octoxbps) I think to remind you. So you can diff the updated file and see if it adds any new useful features, and the original modified one stays in place. This only applies to files xbps understands to be conf files though.
I don’t use suspend or sleep so can only add best of luck with that :clapper:


A quick idea I had. Modify acpi to be aware of other power utilities and used those if they are installed.

A pseudo code example:
if lid-event-occurs check 1: see if any other system has some option set check 2: do the standard thing fi

This should be a good enough solution to everyone. If you don’t have other utils then nothing will happen. And if you do, your options will be followed. However, there could be a point of failure here. We don’t know how DEs and other power managers handle this, so writing the code would require you to learn this and it may be a very messy path (different systems, events, weird cases for specific DEs, etc). Sigh

(Masato the Empty) #23

Interesting. I played with it before posting, and I didn’t see the new version. All I saw was a message stating that modified config file won’t be overwritten.

So I guess I’ll need to add that to the list of things I need to look into, because if that’s the case, then it’s potentially very useful. Thanks @hralgmir

(Masato the Empty) #24

That’s always the trick isn’t it?

I think Void ships with the simplest methods and assumes that it should be easy enough for the user to make any customizations he wants.

You start trying to write scripts to do things that were not hard to do manually, but tedious, and you realize how complicated our own logic is and that we do it without thinking about (since as soon as you start thnking about it, you bang your head against the wall and wonder why it’s so damn hard to script something so simple!)

Historically, I’ve often found that most systems make the wrong assumptions about my own uses/preferences, but it’s always been worse when they try to do everything for me; fixing that always took more work to remedy than if they’d just left me on my own…

# Template file for 'acpid'
conf_files="/etc/acpi/events/anything /etc/acpi/handler.sh"
# Template file for 'grub'
conf_files="/etc/default/grub /etc/grub.d/40_custom"

Presumably they are handled in the same way, but long term testing is the only sure way!


@masato Before I changed the $2 to a $3 the script caused my computer to suspend everytime I closed its lid. After I changed the $2 to a $3 the computer no longer does that. Which is the way it is supposed to be when all of the settings that I’ve made elsewhere are taken into consideration. (The changes I made, are directly from the Manjaro script

So as far as I’m concerned the script has a problem, that my changes have fixed.

If you still don’t think that there is anything wrong with the original script that’s fine & its your prerogative. :slight_smile:

Here is the Manjaro script that I learned from:


Default acpi script that takes an entry for all actions

case “$1” in
case “$2” in
logger ‘PowerButton pressed’
logger “ACPI action undefined: $2”
case “$2” in
logger ‘SleepButton pressed’
logger “ACPI action undefined: $2”
case “$2” in
case “$4” in
logger ‘AC unpluged’
logger ‘AC pluged’
logger “ACPI action undefined: $2”
case “$2” in
case “$4” in
logger ‘Battery online’
logger ‘Battery offline’
*) logger “ACPI action undefined: $2” ;;
case “$3” in
logger ‘LID closed’
logger ‘LID opened’
logger “ACPI action undefined: $3”
logger “ACPI group/action undefined: $1 / $2”

vim:set ts=4 sw=4 ft=sh et:[/code]

I’m currently using it with the vvv back in the place that the Void script has it, with no negative side effects (meaning each time I close the lid my machine does NOT suspend.


Hey @handy, glad this worked. Just a few questions before I try this myself. If you change the lid action in your DE (say you want your laptop to go too sleep when you close the lid). Does it work now?

Does zzz lock your computer and asks you for a password?

Thanks in advance!


@ferviron I don’t know. I’ve never had the need to use suspend, my notebook is too heavy (powerful desktop replacement type, always plugged in to AC) & hungry for electricity.

Make a copy of your handler.sh as a backup & then edit the original & test it out. If it doesn’t work for your needs then copy the original back over it. :slight_smile:

Later on I’ll get to my notebook & see if suspend works for you.


In /etc/zzz.d/ there are two folders where you can add scripts that are executed when you run zzz. You can manually add locking this way (remember to write with &). You can read about this in the manpage for zzz


The comment about zzz was just to point out it didn’t lock the system. I may have mixed my problem with just giving out information. I believe zzz works as it should by not locking the system. The plethora of screen lockers available do work with no problem whatsoever, so zzz just suspending the system is completely fine.

Thanks @handy I’ll report back this weekend.

(vdo) #31

I have a similar problem with a Thinkpad X260.
I use i3 with xfce4-power-settings, and I would like to have the ability to close the lid, leaving the laptop on.

I tried many many things:

  • Editing the ACPI handlers.
  • Changing and removing xfce4-power-settings
  • Uninstalling acpid
  • removing zzz and ZZZ
  • Older kernels
  • Kernel parameters to acpi
  • Etc…

No luck, every time I close the lid the laptop suspends and I cannot wake it up (I need to hold power for 3s and boot again.)

It’s really frustrating…
I will need, after all those years, to patch and compile the kernel again?


@vdo On my Thinkpad x200s’s fresh install of Void recently it was like that, it would stay on even with the lid closed. But I wanted the opposite so I found out to enable the acpid service for it to start suspending on close.

I’m not able to give any idea on how to fix your problem, but I thought I’d give my experience.

(Masato the Empty) #34

If you don’t even have acpid running, then the issue is probably not related to acpi (though it is still possible that you have some other program intercepting lid events, I don’t know what programs in Void listen to that aside from acpid but it would have to be some other running program taking action when you generate a lid event)

It’s also possible that the behavior you see is internal to the laptop hardware/controllers (in which case it may be possible to affect it via some driver parameter, though what that would be is up to you to figure out based on your hardware, and to do that, you’ll need to figure out more of what’s really going on).

Are you even sure that your system is going to sleep and getting stuck? If you have another computer on your network, I’d recommend using ssh to connect to the Void laptop, then shutting the lid to see if you get disconnected. If you do then that would confirm that something is still trying to send your laptop to a suspend state. However, if it does not and you are still connected to the system, then something else is going on, and you have to figure out what.

(vdo) #35

@masato I happens also without X, almost everything stopped.
It has something to do with the hardware …
When it goes to sleep, the power led blinks fading slowly, and there’s no connectivity. I tried many combinations of keys, no luck :disappointed_relieved:

(vdo) #36

Thanks @royaldibble
I had many thinkpads in my life. x220, x230 (this one), x240 and x260. I know them pretty well and that’s the first time it happens!

(kenny_w) #37

Thank you handy!!! You saved me! I was just about to go out for a smoke(I use my netbook to watch videos/play games while I’m smoking) when I noticed that closing my laptop’s lid made the sound stop! One google search & PRESTO I have a fix!! I’ve been slaving away working at learning Void Linux for the past couple days & I’m so happy I don’t have to sit here until 2AM just to figure out how to prevent it from stopping stuff when the lid gets closed, THANK YOU! I was on the verge of pulling my hair out!

Now, the main reason I’m leaving a comment here is because when I apply the settings in mate-power-manager or xfce4-power-manager, the settings don’t actually work, like when I choose “do nothing” on the lid closing, its not actually ‘doing nothing’, so this “bug” is still there, the xfce4- and mate-power-manager aren’t applying the setting properly. I don’t mean to necro-bump but I feel that this input is relevant & possibly needed for the betterment of Void Linux!

Cheers everyone!


Please could you explain a little more what “saved you” ? What was the “fix” ?


(kenny_w) #39

in /etc/acpi/handler.sh

button/lid) case “$3” in close) logger ‘LID closed’ ;; open) logger ‘LID opened’ ;; *) logger “ACPI action undefined: $3” ;; esac

this was the fix. I just changed the config file so this one part looked like this, which is why I thanked handy for it.
I’m really liking this Linux distro! You guys have done a great job on this thing! Very unique, not just another Ubuntu/Debian-based distro!


You could make an effort to format the text correctly, like it is in the real file…

(kenny_w) #41

I don’t really understand what you mean by “Correctly”… I just copied what handy wrote and it worked…