Shutdown script possible to alert about connected USB devices?
When I shutdown, I would like to be alerted if any USB device is still plugged into my system. For comparison: on windows I use:
4sysops.com/archives/never-forget-your-usb-stick-again Does anything like it exist or can anyone point me to how this can be accomplished? It should follow the following very simple logic:
|
You'll need to use the "lsusb" command:
Code:
lsusb | grep "Memory Stick Identifier String" |
Ok, I am getting USB-stick and bluetooth with the following:
Quote:
Now I need to hook it into the shutdown sequence somehow if it displays a non-empty list. Any hints for me? I am an utter newby... This the way to go? Quote:
|
shutdown -k
Running
Code:
/sbin/shutdown -k "warning-message: remove USB devices" Making it part of some shell script would allow to wait for some confirmation and then call the real shutdown sequence. |
That would be the "dumb" way of doing it, right? Knowing myself, I will hit return without thinking after 5 times and still forget my stick.
Not what I want. There should be a place for the less organized computer users as well. |
This all depends on how you shutdown...do you:
1. use shutdown from gnome system menu? 2. use the shutdown command from a terminal? If you are using shutdown from xterm, you can do something like the following example in your .bashrc: Code:
shutdown() { You can however do this: 1. disable shutdown in gnome https://www.redhat.com/archives/fedo.../msg01903.html 2. map hotkey to a shutdown script. Fire up gconf-editor (you may have to install it...run "yum gconf-editor" if its not installed), browse in /apps/metacity/global_keybindings, change the value of any run_command not used (e.g. run_command_1) and map for example, <shift>F1 to it. 3. map command to hotkey. Create a script called /root/bin/sd.sh, and in gconf-editor, goto /apps/metacity/keybinding_commands, and map say, command_1, to /root/bin/sd.sh. Here's an example of what you could put into sd.sh: Code:
#!/bin/bash |
Thx Kenosi,
From what I found out, there might not be an easy way to accomplish this. This looks as good as can be then. I am a KDE user, but I guess the only difference would be in disabling shutdown. |
All times are GMT -5. The time now is 07:33 PM. |