By creating the above two files, I created systemd to disable wake-up by mouse and keyboard operations.
After trying to restart manjaro three times in a row, I was able to confirm that the wakeup setting was not reset and I was unable to wake it from sleep.
However, when I turned off the power, started manjaro the next day, and then went to sleep, I was able to wake up again from the mouse and keyboard, and wakeup was not disabled.
systemctl status wakeup-disabled 1 ✘
× wakeup-disabled.service - Disable wakeup events on startup
Loaded: loaded (/etc/systemd/system/wakeup-disabled.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Sun 2023-09-24 08:59:22 JST; 2h 7min ago
Process: 499 ExecStart=/bin/bash /home/muro/.bin/wakeup-disabled.sh (code=exited, status=1/FAILURE)
Main PID: 499 (code=exited, status=1/FAILURE)
CPU: 3ms
9月 24 08:59:22 manjaro systemd[1]: Starting Disable wakeup events on startup...
9月 24 08:59:22 manjaro bash[499]: /home/muro/.bin/wakeup-disabled.sh: 行 3: /sys/bus/usb/devices/3-2.1/power/wakeup: そのようなファイルやディレクトリはありません
9月 24 08:59:22 manjaro bash[499]: /home/muro/.bin/wakeup-disabled.sh: 行 4: /sys/bus/usb/devices/3-2.2/power/wakeup: そのようなファイルやディレクトリはありません
9月 24 08:59:22 manjaro systemd[1]: wakeup-disabled.service: Main process exited, code=exited, status=1/FAILURE
9月 24 08:59:22 manjaro systemd[1]: wakeup-disabled.service: Failed with result 'exit-code'.
9月 24 08:59:22 manjaro systemd[1]: Failed to start Disable wakeup events on startup.
(Sorry, the above message contains Japanese.)
It seems that the command in the sh file is failing to execute, but the message “No such file or directory” is displayed even though the wakeup file exists.
Usually: Go into your UEFI Settings and disable" wake up by usb inputs" at the power management section. The option can be called differently.
If not possible, then here is a more reliable version of your script:
#!/bin/bash
# Toggle wakeup device (enabled/disabled)
echo "XHC" > /proc/acpi/wakeup
# If enabled, it will be disabled or if disabled, it will be enabled.
Check to which address path it is symlinked to:
file /sys/bus/usb/devices/*
For example: 0000:00:14.0
and compare with:
cat /proc/acpi/wakeup
Adjust “XHC” above.
You can also use something like that:
while read line
do
mapfile -t -d' ' <<<"$line"
[[ "${MAPFILE[2]}" == '*disabled' ]] && continue
if [[ "${MAPFILE[2]}" == '*enabled' ]] \
&& [[ "${MAPFILE[0]}" == 'XHC' ]]; then
echo "Disabling ${MAPFILE[3]}"
# Uncomment the following to run it:
# echo "${MAPFILE[0]}" > /proc/acpi/wakeup
fi
done < <(cat /proc/acpi/wakeup | tr '\t' ' ' | tr -s ' ')
The problem is USB number e.g. “3-2.1” that can be randomly changed after many reboots.
How to fix 1. issue:
You need to get idVendor and idProduct, they are the identity of your device.
Run $ lsusb to display idVendor and idProduct of your device.
2. issue:
Your script of systemd service is run once after reboot and works. But it does not work when you disconnect and reconnect your mouse without rebooting, because the USB setting of the mouse is reset after reconnecting the USB port.
How to fix 2. issue:
Create a udev-rule script /etc/udev/rules.d/90-disable-mouse.rules:
XXXX is idVendor.
YYYY is idProduct.
Thank you for your reply.
After rewriting the sh file as above and restarting manjaro, I was unable to wake up even if I operated the mouse and keyboard during sleep.
I’ll see how it goes for a few days.
file /sys/bus/usb/devices/* 3 ✘
/sys/bus/usb/devices/1-0:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-0:1.0
/sys/bus/usb/devices/1-7: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-7
/sys/bus/usb/devices/1-7:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-7/1-7:1.0
/sys/bus/usb/devices/1-8: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-8
/sys/bus/usb/devices/1-8:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-8/1-8:1.0
/sys/bus/usb/devices/1-8:1.1: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-8/1-8:1.1
/sys/bus/usb/devices/1-8:1.2: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1/1-8/1-8:1.2
/sys/bus/usb/devices/2-0:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb2/2-0:1.0
/sys/bus/usb/devices/3-0:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-0:1.0
/sys/bus/usb/devices/3-2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2
/sys/bus/usb/devices/3-2.1: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.1
/sys/bus/usb/devices/3-2.1:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.1/3-2.1:1.0
/sys/bus/usb/devices/3-2.1:1.1: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.1/3-2.1:1.1
/sys/bus/usb/devices/3-2.1:1.2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.1/3-2.1:1.2
/sys/bus/usb/devices/3-2.2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.2
/sys/bus/usb/devices/3-2.2:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.2/3-2.2:1.0
/sys/bus/usb/devices/3-2.2:1.1: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.2/3-2.2:1.1
/sys/bus/usb/devices/3-2.2:1.2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2.2/3-2.2:1.2
/sys/bus/usb/devices/3-2:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3/3-2/3-2:1.0
/sys/bus/usb/devices/4-0:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb4/4-0:1.0
/sys/bus/usb/devices/4-2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb4/4-2
/sys/bus/usb/devices/4-2:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb4/4-2/4-2:1.0
/sys/bus/usb/devices/5-0:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5/5-0:1.0
/sys/bus/usb/devices/5-1: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5/5-1
/sys/bus/usb/devices/5-1:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5/5-1/5-1:1.0
/sys/bus/usb/devices/5-1:1.1: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5/5-1/5-1:1.1
/sys/bus/usb/devices/5-1:1.2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5/5-1/5-1:1.2
/sys/bus/usb/devices/5-2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5/5-2
/sys/bus/usb/devices/5-2:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5/5-2/5-2:1.0
/sys/bus/usb/devices/6-0:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-0:1.0
/sys/bus/usb/devices/6-2: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-2
/sys/bus/usb/devices/6-2:1.0: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6/6-2/6-2:1.0
/sys/bus/usb/devices/usb1: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb1
/sys/bus/usb/devices/usb2: symbolic link to ../../../devices/pci0000:00/0000:00:02.1/0000:02:00.0/usb2
/sys/bus/usb/devices/usb3: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb3
/sys/bus/usb/devices/usb4: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.3/usb4
/sys/bus/usb/devices/usb5: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb5
/sys/bus/usb/devices/usb6: symbolic link to ../../../devices/pci0000:00/0000:00:08.1/0000:07:00.4/usb6
Never use your home directory for things that must be executed at the system level. Put your script in /usr/local/bin, chown it to root:root, and give it 755 (-rwxr-xr-x) permissions. You either way don’t have write access to anything under /proc as a regular user, so your script would fail.