pub / pp-notifier

Instant Messenger Notification daemon for the PinePhone
git clone https://https://src.jayvii.de/pub/pp-notifier.git
Home | Log | Files | Exports | Refs | README | RSS

commit 14a44ec5c05d69dc461410d0c3e9642171d9bcd5
parent c9bcac79ab0f4dd10a90f6c83a56a573945ff3e1
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Mon, 23 Aug 2021 11:37:07 +0200

Fixing typos and add notification

Diffstat:
Aim-notifier.desktop | 8++++++++
Aim-notifier.service | 9+++++++++
Mim-notifier.sh | 13++++++++++---
3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/im-notifier.desktop b/im-notifier.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Instant Message Notifier +Exec=$HOME/.local/bin/im-notifier.sh +Terminal=false +Categories=Network +Type=Application +StartupNotify=false +X-GNOME-Autostart-enabled=true diff --git a/im-notifier.service b/im-notifier.service @@ -0,0 +1,9 @@ +[Unit] +Description=Instant Messaage Notifier + +[Service] +ExecStart=%h/.local/bin/im-notifier.sh +Restart=always + +[Install] +WantedBy=default.target diff --git a/im-notifier.sh b/im-notifier.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash +# Set timings POLLTIME=30 TIMEOUT=25 +# Telegram Settings TELEGRAM=1 TG_NOTIFICATION_ID=0 @@ -15,7 +17,7 @@ function im_notify { --object-path=/org/freedesktop/Notifications \ --method=org.freedesktop.Notifications.Notify \ "$1" $2 "$3" "$1" "$4" '[]' '{"category": <"im.received">}' 3000 - echo 1 > /sys/devices/platform/leds/leds/pinephone\:blue/brightness + echo 1 > /sys/devices/platform/leds/leds/blue\:indicator/brightness } function im_unnotify { gdbus call --session \ @@ -23,7 +25,7 @@ function im_unnotify { --object-path=/org/freedesktop/Notifications \ --method=org.freedesktop.Notifications.CloseNotification \ $1 - echo 0 > /sys/devices/platform/leds/leds/pinephone\:blue/brightness + echo 0 > /sys/devices/platform/leds/leds/blue\:indicator/brightness } ## Telegram @@ -44,8 +46,13 @@ function tg_notify { # Run Daemon ------------------------------------------------------------------ +# Notify user about running state of the daemon +im_notify "IM-Notifier" 0 "gnome-settings" "IM-Notifier is running..." + +# Run daemon in endless while-loop while :; do + # Telegram if [[ $TELEGRAM != 0 ]]; then # kill after some time @@ -59,7 +66,7 @@ while :; do TG_NOTIFICATION_ID=$(tg_notify \ "$TG_UNREAD" $TG_NOTIFICATION_ID | \ sed -e 's/^.*\s//' -e 's/[^0-9]//g') - else + elif [[ $TG_NOTIFICATION_ID != 0 ]]; then # Close Notification im_unnotify $TG_NOTIFICATION_ID TG_NOTIFICATION_ID=0