Created
February 10, 2011 18:03
-
-
Save telent/820990 to your computer and use it in GitHub Desktop.
display gnome notification-area thing whenever rsync is running
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/bash | |
function in_progress() { | |
notify-send "Backup running" "The backup is running. Please don't unplug Fred"; | |
}; | |
#PID=/tmp/hello/rsnapshot-running | |
#POLL=10 | |
GROUP=users # could make this plugdev or staff or whoever | |
POLL=120 | |
PID=/var/run/rsnapshot.pid | |
if ! ( id -a | grep -q $GROUP ) ; then | |
echo "Not a member of the $GROUP group, exiting" >&2 | |
exit 0 | |
fi | |
if [ x$DISPLAY = x ] ; then | |
echo "DISPLAY unset, exiting" >&2 | |
fi | |
while xset q >/dev/null ; do | |
until test -f $PID ; do inotifywait `dirname $PID` 2>/dev/null ;done | |
xset q >/dev/null || exit 0 | |
in_progress | |
while test -f $PID ;do | |
if zenity --notification --text "Backup in progress" --window-icon=/usr/share/icons/gnome/48x48/actions/document-save.png --timeout $POLL ;then | |
# zenity returns true if the icon is clicked, show a message. | |
test -f $PID && in_progress | |
fi | |
done | |
notify-send -t 10000 "Backup finished" "The backup has finished. It is safe to unplug Fred now" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires inotify-tools
The xset q calls are probably not as necessary as I thought they were when I added them, but are supposed to make the script die when DISPLAY goes away