Skip to content

Instantly share code, notes, and snippets.

@fanoush
Created November 9, 2024 11:23
Show Gist options
  • Save fanoush/a27ba83916b132925a9d9487269e6a1b to your computer and use it in GitHub Desktop.
Save fanoush/a27ba83916b132925a9d9487269e6a1b to your computer and use it in GitHub Desktop.
disable/enable wake up of ACPI devices
#!/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