Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@kepi 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

This comment has been minimized.

Copy link

@RodJLinux RodJLinux commented Jan 7, 2017

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

@MaMrEzO

This comment has been minimized.

Copy link

@MaMrEzO 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