commit de09a18972694c280256e8a21c1d0fe999a0833f
parent bee2ba9583d7b961ccbbef750d249228a62df1b9
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Mon, 23 Aug 2021 11:58:25 +0200
Support non-phosh desktops as well
Diffstat:
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
@@ -49,9 +49,15 @@ cd Notifier
make install
```
-This will place `im-notifier.sh` into `~/.local/bin/im-notifier.sh` and places
-the systemd-service file under your user's directory. You can enable & start
-im-notifier with:
+This will place `im-notifier.sh` into `~/.local/bin/im-notifier.sh` and
+`im-notifier.desktop` into `~/.config/autostart/im-notifier.desktop`. The
+later makes sure, that the daemon ist started when starting the desktop
+session.
+
+In Order to start the daemon directly after installation, restart your
+current desktop session or run the script manually:
+
```
-systemctl --user enable im-notifier --now
+# Phosh:
+pkill phosh
```
diff --git a/im-notifier.sh b/im-notifier.sh
@@ -12,19 +12,27 @@ TG_NOTIFICATION_ID=0
## Common
function im_notify {
- gdbus call --session \
- --dest=org.freedesktop.Notifications \
- --object-path=/org/freedesktop/Notifications \
- --method=org.freedesktop.Notifications.Notify \
- "$1" $2 "$3" "$1" "$4" '[]' '{"category": <"im.received">}' 3000
+ if [[ "$XDG_CURRENT_DESKTOP" == "GNOME:Phosh" ]]; then
+ gdbus call --session \
+ --dest=org.freedesktop.Notifications \
+ --object-path=/org/freedesktop/Notifications \
+ --method=org.freedesktop.Notifications.Notify \
+ "$1" $2 "$3" "$1" "$4" '[]' '{"category": <"im.received">}' 3000
+ else
+ # unfortunately, this does not replace old messages
+ notify-send --app-name="$3" --icon="$3" --category="im.received" \
+ "$1" "$4"
+ fi
echo 1 > /sys/devices/platform/leds/leds/blue\:indicator/brightness
}
function im_unnotify {
- gdbus call --session \
- --dest=org.freedesktop.Notifications \
- --object-path=/org/freedesktop/Notifications \
- --method=org.freedesktop.Notifications.CloseNotification \
- $1
+ if [[ "$XDG_CURRENT_DESKTOP" == "GNOME:Phosh" ]]; then
+ gdbus call --session \
+ --dest=org.freedesktop.Notifications \
+ --object-path=/org/freedesktop/Notifications \
+ --method=org.freedesktop.Notifications.CloseNotification \
+ $1
+ fi
echo 0 > /sys/devices/platform/leds/leds/blue\:indicator/brightness
}