From fe05b91db4a47f66cd0862734fca5aec84a6cf0f Mon Sep 17 00:00:00 2001 From: James Barnett Date: Tue, 7 Nov 2017 13:04:01 -0500 Subject: [PATCH] make libnotify optional --- bin/snap-sync | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/snap-sync b/bin/snap-sync index cdc993e..2a9d9b8 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -39,6 +39,12 @@ mkfifo $PIPE systemd-cat -t "$name" < $PIPE & exec 3>$PIPE +donotify=0 +which notify-send &> /dev/null +if [[ $? -ne 0 ]]; then + donotify=1 +fi + notify() { for u in $(users | sed 's/ /\n/' | sort -u); do sudo -u $u DISPLAY=:0 \ @@ -48,11 +54,19 @@ notify() { } notify_info() { - notify "$1" "$2" "information" + if [[ $donotify -eq 0 ]]; then + notify "$1" "$2" "information" + else + printf "$1: $2\n" + fi } notify_error() { - notify "$1" "$2" "error" + if [[ $donotify -eq 0 ]]; then + notify "$1" "$2" "error" + else + printf "$1: $2\n" + fi } error() {