Thanks for the link. It looks exactly like what I need.
How could I set it up so that this happens before suspend and undo's after I come out of suspend?
Thanks for the link. It looks exactly like what I need.
How could I set it up so that this happens before suspend and undo's after I come out of suspend?
OK, I put the script shown below in directory
/usr/lib/pm-utils/sleep.d
I named it 85test (bit of a guess, the scripts in this directory run in sequence according to the 2-digit prefix) and made it executable with
Script:Code:sudo chmod ugo+x 85test
This produced a file /var/log/miketest.txt with two lines saying 'suspend' and 'resume' when I did the suspend/resume operation.Code:#!/bin/sh ## ## suspend-example.sh ## case $1 in suspend) ## COMMANDS THAT YOU WISH TO RUN BEFORE SUSPEND echo suspend > /var/log/miketest.txt ;; resume) ## COMMANDS THAT YOU WISH TO RUN AFTER RESUME echo resume >> /var/log/miketest.txt ;; hibernate) ## COMMANDS THAT YOU WISH TO RUN BEFORE HIBERNATE echo hibernate ;; thaw) ## COMMANDS THAT YOU WISH TO RUN AFTER RESUME FROM SUSPEND TO DISK echo thaw ;; esac
So if the echo commands I described earlier work OK you should be able to just plug them into the script above instead of the logging commands.
Actually you might want to include some logging commands as well as the USB related commands while you're testing, just to prove the script is running, then remove them when working OK.
Credit: Script sample was found here:
http://myricci.com/index.php?option=...id=41&Itemid=9
Last edited by mikechant; January 26th, 2010 at 07:56 PM. Reason: add credit
Not sure what happened. But, usually when I click the power button it goes into Suspend. I pressed it this time and I hibernated. Perhaps a bug with the script?
All,
This is the script I'm using now which has resolved the issue for me in Ubuntu 9.04.
Which produces the following log:user@pc:/usr/lib/pm-utils/sleep.d$ cat 85usb_power_mgmt
#!/bin/sh
##
## 85usb_power_mgmt
##
case $1 in
suspend)
## COMMANDS THAT YOU WISH TO RUN BEFORE SUSPEND
echo "$(date): suspend" >> /var/log/usb_power_mgmt.txt
;;
resume)
## COMMANDS THAT YOU WISH TO RUN AFTER RESUME
echo "$(date): suspend-resume" >> /var/log/usb_power_mgmt.txt
modprobe -r -v whci_hcd && modprobe -v whci_hcd
;;
hibernate)
## COMMANDS THAT YOU WISH TO RUN BEFORE HIBERNATE
echo "$(date): hibernate" >> /var/log/usb_power_mgmt.txt
;;
thaw)
## COMMANDS THAT YOU WISH TO RUN AFTER RESUME FROM SUSPEND TO DISK
echo "$(date): hibernate-thaw" >> /var/log/usb_power_mgmt.txt
modprobe -r -v whci_hcd && modprobe -v whci_hcd
;;
esac
The important thing out of this is from the script:user@pc:/usr/lib/pm-utils/sleep.d$ cat /var/log/usb_power_mgmt.txt
Sun Jun 27 17:58:21 EDT 2010: hibernate
Sun Jun 27 17:59:40 EDT 2010: hibernate-thaw
Sun Jun 27 18:00:37 EDT 2010: hibernate
Sun Jun 27 18:49:19 EDT 2010: hibernate-thaw
Sun Jun 27 20:22:51 EDT 2010: hibernate
Sun Jun 27 20:23:57 EDT 2010: hibernate-thaw
Sun Jun 27 20:32:58 EDT 2010: hibernate
Sun Jun 27 20:34:00 EDT 2010: hibernate-thaw
Sun Jun 27 20:36:14 EDT 2010: hibernate
Sun Jun 27 20:37:24 EDT 2010: hibernate-thaw
Sun Jun 27 20:48:46 EDT 2010: hibernate
Sun Jun 27 20:49:54 EDT 2010: hibernate-thaw
Essentially this is removing the usb driver, and reloading it after resuming from suspend (RAM) or hibernation (disk). This worked for me in Ubuntu 9.04, but you might have to replace whci_hcd with a different driver...mileage may varymodprobe -r -v whci_hcd && modprobe -v whci_hcd
Can someone please confirm this resolves the issue for them on the same and/or different Ubuntu releases?
~Fermmy
Bookmarks