Created
June 15, 2012 11:52
-
-
Save nuklea/2936084 to your computer and use it in GitHub Desktop.
Script for corrent unbind usb devices before suspend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Put this file into /etc/pm/sleep.d and don't forget | |
# `chmod +x to /etc/pm/sleep.d/20custom-hcd.sh' | |
# See http://ubuntuforums.org/showpost.php?p=11534892&postcount=88 | |
TMPLIST=/tmp/hdc-dev-list | |
case "${1}" in | |
hibernate|suspend) | |
> $TMPLIST | |
for i in $(find /sys/bus/pci/drivers/{xhci,ehci}_hcd | egrep '[0-9a-z]+\:[0-9a-z]+\:.*$'); do | |
device=$(basename $i) | |
path=$(dirname $i)/unbind | |
echo "Unbind device $device in $path" | |
echo -n $device > $path | |
echo $i >> $TMPLIST | |
done | |
;; | |
resume|thaw) | |
for i in $(cat $TMPLIST); do | |
device=$(basename $i) | |
path=$(dirname $i)/bind | |
echo "Bind device $device in $path" | |
echo -n $device > $path | |
done | |
rm $TMPLIST | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment