From 5ad6923d8c089e2a5aa91b056889612227af84c5 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sun, 29 Jan 2017 19:27:03 -0600 Subject: [PATCH] notify all logged in users (#20) --- bin/snap-sync-wrapper | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/snap-sync-wrapper b/bin/snap-sync-wrapper index dc26616..8997697 100755 --- a/bin/snap-sync-wrapper +++ b/bin/snap-sync-wrapper @@ -1,10 +1,17 @@ #!/bin/bash -sudo -u $USER DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus notify-send 'Starting snap-sync backups to $1...' --icon=dialog-information +# Notifies all users that a backup is running -#/usr/bin/snap-sync --UUID $1 --noconfirm -if [[ $? == 0 ]]; then - sudo -u $USER DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus notify-send 'snap-sync backups to $1 complete!' --icon=dialog-information -else - sudo -u $USER DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus notify-send 'Error in snap-sync backups. Check journal for more information.' --icon=dialog-information -fi +for u in $(users); do + + notify_cmd="sudo -u $u DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus notify-send" + $notify_cmd 'Starting snap-sync backups to '$1'...' --icon=dialog-information + + /usr/bin/snap-sync --UUID $1 --noconfirm + if [[ $? == 0 ]]; then + $notify_cmd 'snap-sync backups to '$1' complete!' --icon=dialog-information + else + $notify_cmd 'Error in snap-sync backups. Check journal for more information.' --icon=dialog-error + fi + +done