Fix desktop notification not shown when DBUS_SESSION_BUS_ADDRESS environment variable is not set

This commit is contained in:
Janek Bevendorff 2016-11-17 00:14:21 +01:00
parent 18a2cc2774
commit e68fed9277
1 changed files with 3 additions and 1 deletions

View File

@ -251,7 +251,9 @@ desktop_notify() {
esac
if [[ "$user" != "" ]]; then
sudo -u "$user" DISPLAY=":0.0" notify-send -i "$icon" -u "$urgency" "rs-backup: $2" "$3"
dbus_pid=$(pgrep -u "$user" dbus-daemon | head -n1)
environment=$(xargs --null < /proc/$dbus_pid/environ)
sudo -u "$user" $environment notify-send -i "$icon" -u "$urgency" "rs-backup: $2" "$3"
fi
}