0

I meant to avoid my laptop waking immediately after suspend. I managed to do so as shown here. The contents of the script disable_devices_from_wakeup.sh I am using is

#!/bin/bash

declare -a devices=(EHC1 EHC3 OHC1 OHC3)
for device in "${devices[@]}" ; do
    sudo sh -c "echo $device > /proc/acpi/wakeup"
done

Now I wanted to make my changes permanent across bootings. So I setup a service as described here and here. The service put together is

$ cat /etc/systemd/system/wakeup_disable_devices.service
[Unit]
Description=Disable devices for wakeup, as a fix to prevent system from waking immediately after suspend

[Service]
ExecStart=/home/user1/Documents/soft-hard-ware/linux-ubuntu/disable_devices_from_wakeup.sh
#ExecStart=/bin/sh -c '/bin/echo EHC1 > /proc/acpi/wakeup'
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

But upon rebooting, the devices are still enabled for wakeup. The service is not running as (I guess) it should:

$ systemctl status wakeup_disable_devices.service
 wakeup_disable_devices.service - Disable devices for wakeup, as a fix to prevent system from waking immediately after suspend
     Loaded: loaded (/etc/systemd/system/wakeup_disable_devices.service; disabled; vendor preset: enabled)
     Active: inactive (dead)

I am not sure how to proceed to make the changes permanent, and to have them automatically applied. I don't know if the problem stems from the sudo in my script, and/or else. I also tried the service with the commented line instead, and it doesn't work either, since cat /proc/acpi/wakeup still shows EHC1 as enabled.

Related:

  1. https://askubuntu.com/questions/252743/how-do-i-prevent-mouse-movement-from-waking-up-a-suspended-computer
  2. https://askubuntu.com/questions/152403/how-do-i-make-changes-to-proc-acpi-wakeup-permanent
  3. Make changes to `/proc/acpi/wakeup` permanent
  4. https://answerbun.com/
  5. https://mitjafelicijan.com/disable-mouse-wake-from-suspend-with-systemd-service.html

2 Answers 2

0

I don't think the service should be "running" because it's not really a service. It's a one-shot action that happens at start then terminates. As such, I suspect the "RemainAfterExit" is making it still appear in systemctl status, albeit as "inactive (dead)". If you add some tell-tale to the script, you can see whether it's actually run. Whether the sudo is a problem isn't clear. Services are not run as your normal user. They may be run as root (so the sudo is redundant but harmless) or as nobody (who does not have sudo permission so it will fail). However, I'm not an Ubuntu user and I find systemd to be more trouble than it's worth. I know how I'd solve this on OpenRC but that won't help you.

0

I was missing a simple step

$ sudo systemctl enable wakeup_disable_devices.service

Plus, I changed to (the brute force) command

ExecStart=sh -c 'echo EHC1 > /proc/acpi/wakeup ; echo EHC3 > /proc/acpi/wakeup ; echo OHC1 > /proc/acpi/wakeup ; echo OHC3 > /proc/acpi/wakeup'

since the more "refined"

ExecStart=sh -c 'devs=(EHC1 EHC3 OHC1 OHC3) ; for dev in "${devs[@]}"; do echo $dev > /proc/acpi/wakeup ; done'

didn't work. I didn't take the time to debug it. Now I don't need an external script anymore.

1
  • Try to use bash -c instead of sh -c on the "refined" example. sh, if it is really sh and not a symlink to bash on your system, won't be able to evaluate such expressions ${devs[@]}
    – mega.venik
    Commented Mar 15, 2023 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .