Created
November 9, 2024 11:23
-
-
Save fanoush/a27ba83916b132925a9d9487269e6a1b to your computer and use it in GitHub Desktop.
disable/enable wake up of ACPI devices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
wakeup(){ | |
wakeup=/proc/acpi/wakeup | |
if [ "$#" -lt 2 ]; then | |
devices=$(grep -e 'bled' $wakeup | cut -f 1 | tr -s '\n' ' ') | |
echo "$0 disable|enable [ $devices]" | |
return 1 | |
fi | |
case $1 in | |
*dis*) state="enabled" ; msg="disabling" ;; | |
*en*) state="disabled" ; msg="enabling" ;; | |
*) return 1 ;; | |
esac | |
matches=$(grep -e "$state" $wakeup | cut -f 1) | |
[ -z "$matches" ] && return 0 | |
shift | |
for d in $* ; do | |
case $matches in *$d*) echo "$d is $state, $msg" ; echo $d >$wakeup ;; esac | |
done | |
} | |
wakeup $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment