Featured image of post Wake Bazzite from Sleep Using a Controller

Wake Bazzite from Sleep Using a Controller

It’s possible, but requires some scripts specific to your system.

Controllers Don’t Wake Linux from Sleep

Putting together a gaming PC with Bazzite makes a home theatre PC pretty console-like, but it lacks a big advantage consoles have: waking the system from sleep and turning one the TV.

The latter requires an HDMI CEC device as a go-between, but the controller waking the system from sleep is possible. It takes some custom scripts to do it. If you aren’t very comfortable in the Terminal, you might want to stick with a mouse or keybard.

These scripts are for informational purposes only. Only try if you are comfortable working with Linux scripts and the Terminal. I am not responsible if you bork your system! Use at your own risk.

Step-by-Step to Enable Wake from USB Device

Controllers don’t have the ability to wake Linux from sleep the way a keyboard does. The work around is to set up a specific USB port to wake the system when there is activity on the port.

The one gatcha with this approach is when you set the system to sleep with the controller, it will send a signal when it shuts off, waking the system back up. A way to deal with this is to just let the system go to sleep on it’s own and only use the controller to wake the system. I have an alternative script at the end of this post to kinda get around this.

Find Your USB Bus

Open the Terminal and run:

1
lsusb

Identify the line corresponding to your controller. For example mine is this:

1
Bus 003 Device 002: ID 2dc8:3106 8BitDo Wireless Adapter

the Bus number is the physical port it is connected to. This doesn’t change.

On my setup, there is a file here /sys/bus/usb/devices/usb3/power/wakeup. Your’s will likely be different.

usb3 is the important part. This wakeup variable controls Bus 003.

It is set to disabled. We want to change that so any activity on that USB port will wake the computer.

Persistent Setup via Udev Rule

Create or edit the file:

1
sudo nano /etc/udev/rules.d/10-wakeup.rules

And add this code. (Replace usb3 with your selected port above.):

1
ACTION=="add", SUBSYSTEM=="usb", KERNEL=="usb3", TEST=="power/wakeup", ATTR{power/wakeup}="enabled"

Save the changes to the file.

Apply and Your Changes

After saving run these terminal commads:

1
2
sudo udevadm control --reload
sudo udevadm trigger

Then suspend your system and test waking with the controller again.

Verify the Changes

You can confirm the rule is applied automatically on boot or after plugging in the device:

1
cat /sys/bus/usb/devices/usb3/power/wakeup

Should return:

1
enabled

Optional: Delay Suspend by 20 Seconds

To give the controller a little bit of time to be shut off before suspend, you can try this script that delays suspend. It works but I didn’t like the flow and just let my system suspend after an idle time set in the Steam OS settings instead.

I would only try this if you are comfortable working with scripots in the Terminal.

Create a Dealy Script

1
/usr/local/bin/delay-suspend.sh

Edit the file:

1
2
3
4
5
6
7
8
9
#!/bin/bash

LOG="/tmp/controller-wakeup.log"

{
    echo "[$(date)] Delaying suspend by 20 seconds..."
    sleep 20
    echo "[$(date)] Proceeding with suspend."
} >> "$LOG" 2>&1

Make it executable:

1
sudo chmod +x /usr/local/bin/delay-suspend.sh

Create a Systemd Service

1
/etc/systemd/system/delay-suspend.service

Add this to the file and save:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[Unit]
Description=Delay suspend for 20 seconds to allow controller shutdown
Before=sleep.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/delay-suspend.sh

[Install]
WantedBy=sleep.target

Enable It:

1
2
3
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable delay-suspend.service

You can verify each suspend event with:

1
cat /tmp/controller-wakeup.log

Video of it Working

Built with Hugo
Theme Stack designed by Jimmy and modified by Josh Nichols.