Skip to content

Instantly share code, notes, and snippets.

@kepi
Created February 27, 2016 15:05
Show Gist options
  • Select an option

  • Save kepi/9dea7aee8a59f3e7c10a to your computer and use it in GitHub Desktop.

Select an option

Save kepi/9dea7aee8a59f3e7c10a to your computer and use it in GitHub Desktop.
#!/bin/bash
# (/usr)/lib/systemd/system-sleep/45fix-usb-wakup
# Disable wakup from USB devices
#
# This is just modification of pm-utils script for systemd sleep hook
# from https://gist.github.com/rutsky/1ed8e9779f0b2941c5a6
[[ "$1" = "pre" ]] || exit 0
function print_state {
cat /proc/acpi/wakeup | grep $1 | cut -f3 | cut -d' ' -f1 | tr -d '*'
}
function disable_wakup {
dev=$1
if [ "`print_state $dev`" == "enabled" ]; then
echo $dev > /proc/acpi/wakeup
fi
}
function enable_wakup {
dev=$1
if [ "`print_state $dev`" == "disabled" ]; then
echo $dev > /proc/acpi/wakeup
fi
}
case $2 in
suspend)
echo "Fixing acpi settings."
# Disable wakup by events from USB hubs
# (e.g. mouse move on some mices)
disable_wakup XHC
;;
esac
@kepi
Copy link
Copy Markdown
Author

kepi commented Feb 27, 2016

You need to check man systemd-suspend.service for correct path for systemd sleep hook scripts (if /usr/lib/... or only /lib/...)

@Reloader01
Copy link
Copy Markdown

Reloader01 commented Sep 5, 2016

Doesn't work in 16.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment