Skip to content

Instantly share code, notes, and snippets.

@rutsky
Created June 8, 2014 19:25
Show Gist options
  • Save rutsky/1ed8e9779f0b2941c5a6 to your computer and use it in GitHub Desktop.
Save rutsky/1ed8e9779f0b2941c5a6 to your computer and use it in GitHub Desktop.
pm-utils script to disable wakup by events from USB devices on Sony Vaio 1311s9rb
#!/bin/bash
# /usr/lib/pm-utils/sleep.d/45fix-usb-wakup
# Disable wakup from USB devices on Sony Vaio 1311s9rb
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 $1 in
hibernate)
echo "Going to suspend to disk!"
;;
suspend)
echo "Fixing acpi settings."
# Disable wakup by events from USB hubs
# (e.g. mouse move on some mices)
disable_wakup XHC
disable_wakup EHC1
disable_wakup EHC2
echo "Suspending to RAM."
;;
thaw)
echo "Suspend to disk is now over!"
;;
resume)
echo "We are now resuming."
;;
*)
echo "Somebody is callin me totally wrong."
;;
esac
@kepi
Copy link

kepi commented Feb 27, 2016

Thanks! Here is modified version for systemd sleep hook for those who are not using pm-utils: https://gist.github.com/kepi/9dea7aee8a59f3e7c10a

@RodJLinux
Copy link

Thanks a bunch ... working perfectly to prevent USB keyboard waking system in Kubuntu 14.04 desktop.

@MaMrEzO
Copy link

MaMrEzO commented Sep 22, 2020

What is purpose of enable_wakup function?
At least its not called inside this script.

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