Skip to content

Instantly share code, notes, and snippets.

@telent telent/
Created Feb 10, 2011

What would you like to do?
display gnome notification-area thing whenever rsync is running
function in_progress() {
notify-send "Backup running" "The backup is running. Please don't unplug Fred";
GROUP=users # could make this plugdev or staff or whoever
if ! ( id -a | grep -q $GROUP ) ; then
echo "Not a member of the $GROUP group, exiting" >&2
exit 0
if [ x$DISPLAY = x ] ; then
echo "DISPLAY unset, exiting" >&2
while xset q >/dev/null ; do
until test -f $PID ; do inotifywait `dirname $PID` 2>/dev/null ;done
xset q >/dev/null || exit 0
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
notify-send -t 10000 "Backup finished" "The backup has finished. It is safe to unplug Fred now"

This comment has been minimized.

Copy link
Owner Author

telent commented Feb 10, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.