Skip to content

Instantly share code, notes, and snippets.

@petersaints
Forked from kepi/45fix-usb-wakup.sh
Last active April 11, 2017 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petersaints/2961faf2a0d799642d60d15073ec6c46 to your computer and use it in GitHub Desktop.
Save petersaints/2961faf2a0d799642d60d15073ec6c46 to your computer and use it in GitHub Desktop.
Disable resume when certain devices (e.g., USB) become active
#!/bin/bash
# (/usr)/lib/systemd/system-sleep/10-fix-proc-acpi-wakeup.sh
# Disable resume when certain devices (e.g., USB) become active.
# Based on: https://gist.github.com/kepi/9dea7aee8a59f3e7c10a
[[ "$1" = "pre" ]] || exit 0
function print_state {
cat /proc/acpi/wakeup | grep $1 | cut -f3 | cut -d' ' -f1 | tr -d '*'
}
function disable_wakeup {
dev=$1
if [ "`print_state $dev`" == "enabled" ]; then
echo $dev > /proc/acpi/wakeup
fi
}
function enable_wakeup {
dev=$1
if [ "`print_state $dev`" == "disabled" ]; then
echo $dev > /proc/acpi/wakeup
fi
}
case $2 in
suspend)
echo "Fixing acpi settings."
# Disable wakeup by events from USB hubs
# (e.g. mouse move on some mices)
disable_wakeup XHC
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment