commit ec3a70e2fef2a2c2810b1de11f5583036b837d2e
parent c5828e092a26ae3f58f5eeb4d757abd0ccbf886a
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Thu, 16 Sep 2021 17:37:40 +0200
Fix execution of actions on signal
Diffstat:
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/im-notifier b/im-notifier
@@ -9,15 +9,13 @@ if [[ -f "$HOME/.config/im-notifier/config" ]]; then
source "$HOME/.config/im-notifier/config"
fi
-# Set timings
+# Set Defaults
if [[ -z $POLLTIME ]]; then
POLLTIME=30
fi
if [[ -z $TIMEOUT ]]; then
TIMEOUT=25
fi
-
-# Telegram Settings
if [[ -z $TELEGRAM ]] && [[ -z $(command -v telegram-cli) ]]; then
TELEGRAM=1
echo "Enabling Telegram!"
@@ -28,6 +26,9 @@ fi
if [[ -z $TG_ACTION ]]; then
TG_ACTION="telegram-desktop"
fi
+
+# Set Initial Notification IDs ------------------------------------------------
+
TG_NOTIFICATION_ID=0
# Modules ---------------------------------------------------------------------
@@ -49,15 +50,11 @@ function im_unnotify {
$1
}
function im_signal_listen {
- while :; do
- INVOKEDACTION=$(dbus-monitor \
- "type='signal',sender='org.freedesktop.Notifications',interface='org.freedesktop.Notifications'" | \
- head -7 | grep -E "im-notify-*")
- if [[ "$INVOKEDACTION" == " string \"im-notify-tg\"" ]]; then
- $SHELL -c "${TG_ACTION}"
- fi
- sleep 5 # actions probably do not happen more often than that
- done
+ dbus-monitor "type='signal',sender='org.freedesktop.Notifications',interface='org.freedesktop.Notifications',member='ActionInvoked'" | \
+ grep -E "$1" | \
+ while read -r line; do
+ $SHELL -c "$2"
+ done
}
## Telegram
@@ -85,8 +82,10 @@ if [[ $TELEGRAM != 0 ]]; then
fi
im_notify "IM-Notifier" 0 "gnome-settings" "$INITMSG" "[]"
-# Run Signal Listener (executes actions)
-im_signal_listen &
+# Run Signal Listeners (executes actions)
+if [[ $TELEGRAM != 0 ]]; then
+ im_signal_listen "im-notify-tg" "${TG_ACTION}" &
+fi
# Run daemon in endless while-loop
while :; do