Merge pull request #47 from tlvince/single-notify

Prevent duplicate notifications
This commit is contained in:
James “Wes” Barnett
2017-07-11 08:10:57 -04:00
committed by GitHub

View File

@@ -39,14 +39,22 @@ mkfifo $PIPE
systemd-cat -t "$name" < $PIPE & systemd-cat -t "$name" < $PIPE &
exec 3>$PIPE exec 3>$PIPE
notify_error() { notify() {
for u in $(users); do for u in $(users | sed 's/ /\n/' | sort -u); do
sudo -u $u DISPLAY=:0 \ sudo -u $u DISPLAY=:0 \
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \ 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 done
} }
notify_info() {
notify "$1" "$2" "information"
}
notify_error() {
notify "$1" "$2" "error"
}
error() { error() {
printf "==> ERROR: %s\n" "$@" printf "==> ERROR: %s\n" "$@"
notify_error 'Error' 'Check journal for more information.' notify_error 'Error' 'Check journal for more information.'
@@ -76,14 +84,6 @@ trapkill() {
trap 'traperror ${LINENO} $? "$BASH_COMMAND" $BASH_LINENO "${FUNCNAME[@]}"' ERR trap 'traperror ${LINENO} $? "$BASH_COMMAND" $BASH_LINENO "${FUNCNAME[@]}"' ERR
trap trapkill SIGTERM SIGINT 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() { usage() {
cat <<EOF cat <<EOF
$name $version $name $version