From c720accf2a91d2fbaba241260dad4fb7ad67522f Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sat, 28 Jan 2017 06:53:14 -0600 Subject: [PATCH 1/3] inital test of libnotify --- systemd/snap-sync@.service | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/systemd/snap-sync@.service b/systemd/snap-sync@.service index 6ce82f5..3eee5a9 100644 --- a/systemd/snap-sync@.service +++ b/systemd/snap-sync@.service @@ -7,6 +7,4 @@ WantedBy=multi-user.target [Service] Type=simple -ExecStart=/usr/bin/snap-sync \ - --UUID %i \ - --noconfirm +ExecStart=/usr/bin/snap-sync-wrapper $i From 51f8429aa9915760b31eb686415606d0c9fcff53 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sat, 28 Jan 2017 07:26:41 -0600 Subject: [PATCH 2/3] add script --- bin/snap-sync-wrapper | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 bin/snap-sync-wrapper diff --git a/bin/snap-sync-wrapper b/bin/snap-sync-wrapper new file mode 100755 index 0000000..dc26616 --- /dev/null +++ b/bin/snap-sync-wrapper @@ -0,0 +1,10 @@ +#!/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 + +#/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 From 5ad6923d8c089e2a5aa91b056889612227af84c5 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sun, 29 Jan 2017 19:27:03 -0600 Subject: [PATCH 3/3] 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