# [Solved] Make only power button wake from suspend?

## jroth

So I'm running Gentoo with Systemd, and I put the system to sleep with:

```
 # systemctl suspend 
```

and then tapping the power button, clicking the mouse, or pressing a key can all wake the system up from suspend. Thing is, it does not like to be woken up with keyboard or mouse click. When it wakes up that way, the screen powers up but remains black, and I think that X has crashed. Also, I just sometimes bump the keyboard or mouse on my desk when I don't mean to and am doing other things. 

So I think it would be best to configure it so that only a power button tap can wake it up from suspend. Anyone know how to do that?Last edited by jroth on Mon Nov 13, 2017 1:03 am; edited 1 time in total

----------

## karmaking

On which events the computer wakes from suspend is usually controlled in the BIOS setup of your computer, not in any system settings. Have you checked if there are any "wake up" or power management options?

Cheers,

Daniel

----------

## jroth

 *karmaking wrote:*   

> On which events the computer wakes from suspend is usually controlled in the BIOS setup of your computer, not in any system settings. Have you checked if there are any "wake up" or power management options?
> 
> Cheers,
> 
> Daniel

 

I dug through the BIOS settings and didn't find anything that would control wake up. Is there anyway to fix this from within Gentoo?

----------

## John R. Graham

Moved from Portage & Programming to Kernel & Hardware on request.

- John

----------

## szatox

 *Quote:*   

> I dug through the BIOS settings and didn't find anything that would control wake up. Is there anyway to fix this from within Gentoo?

 I honestly doubt it. I don't think CPU is in control at this time, that would kinda defeat the purpose of suspend mode. You know, you want to power off as many circuits as possible, when you wait for an interrupt. I'd expect to find this logic somewhere in the south bridge... Close to the "interface devices"

----------

## jroth

 *szatox wrote:*   

>  *Quote:*   I dug through the BIOS settings and didn't find anything that would control wake up. Is there anyway to fix this from within Gentoo? I honestly doubt it. I don't think CPU is in control at this time, that would kinda defeat the purpose of suspend mode. You know, you want to power off as many circuits as possible, when you wait for an interrupt. I'd expect to find this logic somewhere in the south bridge... Close to the "interface devices"

 

Hm, OK. In that case, is there anything I can do to diagnose the fact that when I wake it up with a mouse click, the computer wakes up but the screen remains black and unresponsive?

----------

## jroth

OK, I've solved it. It turns out you can control this from the OS, via a file called

```
/proc/acpi/wakeup
```

That file tells you what things are enabled to wake the system up. You can toggle their state by (as root) echoing the name of the device at the file, for example:

```

# echo PS2K > /proc/acpi/wakeup

```

that would toggle the wake-up state of my PS2 keyboard. I wrote this script which will disable all of the devices except for my power button (called PWRB):

```

#!/bin/bash

for f in $(cat /proc/acpi/wakeup | grep "enabled" |  grep -v "PWRB"  | cut -d ' '  -f 1)

do

        echo $f > /proc/acpi/wakeup

done

```

Then configured SystemD to run that script on boot. The state of /proc/acpi/wakeup appears to be preserved after waking up from suspend, at least on my machine.

----------

## Hu

That script could be greatly simplified.  Remove the useless use of cat.  Fold the two text searches into a single gawk program.  Use gawk's word splitting to replace the cut:

```
gawk '/enabled/ && ! /PWRB/ { print $1; }' < /proc/acpi/wakeup | while read f; do

    echo "$f" > /proc/acpi/wakeup

done
```

----------

