make libnotify optional

This commit is contained in:
James Barnett
2017-11-07 13:04:01 -05:00
parent 34ef2fa185
commit fe05b91db4

View File

@@ -39,6 +39,12 @@ mkfifo $PIPE
systemd-cat -t "$name" < $PIPE & systemd-cat -t "$name" < $PIPE &
exec 3>$PIPE exec 3>$PIPE
donotify=0
which notify-send &> /dev/null
if [[ $? -ne 0 ]]; then
donotify=1
fi
notify() { notify() {
for u in $(users | sed 's/ /\n/' | sort -u); do for u in $(users | sed 's/ /\n/' | sort -u); do
sudo -u $u DISPLAY=:0 \ sudo -u $u DISPLAY=:0 \
@@ -48,11 +54,19 @@ notify() {
} }
notify_info() { notify_info() {
if [[ $donotify -eq 0 ]]; then
notify "$1" "$2" "information" notify "$1" "$2" "information"
else
printf "$1: $2\n"
fi
} }
notify_error() { notify_error() {
if [[ $donotify -eq 0 ]]; then
notify "$1" "$2" "error" notify "$1" "$2" "error"
else
printf "$1: $2\n"
fi
} }
error() { error() {