diff --git a/bin/snap-sync b/bin/snap-sync index 43bd23f..686fcb7 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -39,14 +39,22 @@ mkfifo $PIPE systemd-cat -t "$name" < $PIPE & exec 3>$PIPE -notify_error() { - for u in $(users); do +notify() { + for u in $(users | sed 's/ /\n/' | sort -u); do sudo -u $u DISPLAY=:0 \ DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \ - notify-send -a $name "$1" "$2" --icon=dialog-error + notify-send -a $name "$1" "$2" --icon="dialog-$3" done } +notify_info() { + notify "$1" "$2" "information" +} + +notify_error() { + notify "$1" "$2" "error" +} + error() { printf "==> ERROR: %s\n" "$@" notify_error 'Error' 'Check journal for more information.' @@ -76,14 +84,6 @@ trapkill() { trap 'traperror ${LINENO} $? "$BASH_COMMAND" $BASH_LINENO "${FUNCNAME[@]}"' ERR trap trapkill SIGTERM SIGINT -notify_info() { - for u in $(users); do - sudo -u $u DISPLAY=:0 \ - DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \ - notify-send -a $name "$1" "$2" --icon=dialog-information - done -} - usage() { cat <