Create a Button to Restart USB in Ubuntu
I've been using my HP w2207 flat panel monitor for some time now. My only frustration has been that I haven't been able to get the USB ports on the side to work unless I have a device plugged in when the computer boots. I think this is more the fault of Ubuntu than it is the monitor. Ubuntu just doesn't seem to care about a USB hub unless there is a device plugged into it. After a little searching on the web I found that a fellow blogger had posted a solution on Hack 2 Live.
Since my wife also uses this computer and she's not nearly as geeky as me, I figured I had better make this a little more automatic. The first step was to write a script to automate the USB restart. Copy the following text into a text editor and save it as /home/userid/bin/usb_reset.
#!/bin/bash## Script *usb_reset*. Place file in ~/bin. Make sure to make executable with "chmod +x usb_reset".# This script must be run as root to work. For desktop launcher, use command "gksudo /home/userid/bin/usb_reset". # Stop USB modprobe -r ehci_hcd wait # Start USB modprobe ehci_hcd exit 0
Now make the file executable. Open a terminal and enter the following commands.
chmod +x usb_reset
You can now try out the script with
If you had a USB drive connected to your hub, then it should have been recognized and mounted automatically.
Now we just need to create the button for our Gnome panel. Right click on the panel and select Add to Panel. Select Custom Application Launcher and click Add. Now in the Create Launcher window enter into the name field
and enter into the command field:
The USB icon should get selected automatically. Click OK.
That's it! You can now restart your USB devices with the click of a button. You will need to enter your password at the prompt if you haven't done any sudo commands recently.