commit f83312fa63a7e06878058ba82b112994960290be
parent e4a165da91f6a828547d73a413da47b86a0478f7
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sun, 19 Sep 2021 22:40:19 +0200
Move tg-notifier to own Repository
Diffstat:
4 files changed, 0 insertions(+), 126 deletions(-)
diff --git a/telegram-notifier/Makefile b/telegram-notifier/Makefile
@@ -1,6 +0,0 @@
-install:
- mkdir -p ${HOME}/.local/bin
- mkdir -p ${HOME}/.config/systemd/user
- install -m 700 ./telegram-notifier.sh ${HOME}/.local/bin/
- install -m 755 ./telegram-notifier.service ${HOME}/.config/systemd/user/
- systemctl --user daemon-reload
diff --git a/telegram-notifier/README.md b/telegram-notifier/README.md
@@ -1,50 +0,0 @@
-# Telegram Notifier
-
-## What does it do?
-
-It checks your current telegram messages via
-`[telegram-cli]`(https://github.com/vysheng/tg) and notifies you about
-any potential messages.
-
-## Why?
-
-The Telegram Desktop client is somewhat ressource intensive, particularly
-on the CPU, leading to high(er) power consumption. With this lightweight
-notifier script, you are not required to have the desktop client running
-in the background at all times.
-
-## Are there system requirements?
-
-Yes.
-
-Checking Telegram Messages: `[telegram-cli]`(https://github.com/vysheng/tg)
-```
-# Debian
-apt install telegram-cli
-```
-
-Set it up via commandline:
-```
-telegram-cli
-```
-
-Sending Notifications: `gdbus` (likely installed already)
-
-## Use Telegram Notifier
-
-Make sure, you fullfill the above requirements and set up `telegram-cli`
-with your account.
-
-Pull this source directory, and run the Makefile:
-```
-git pull https://src.jayvii.de/Hobby/PinePhoneScripts
-cd PinePhoneScripts/telegram-notifier
-make install
-```
-
-This will place `telegram-notifier.sh` into `~/.local/bin/telegram-notifier.sh`
-and places the systemd-service file under your user's directory. You can enable
-& start telegram-notifier with:
-```
-systemctl --user enable telegram-notifier --now
-```
diff --git a/telegram-notifier/telegram-notifier.service b/telegram-notifier/telegram-notifier.service
@@ -1,9 +0,0 @@
-[Unit]
-Description=Telegram Notifier
-
-[Service]
-ExecStart=%h/.local/bin/telegram-notifier.sh
-Restart=always
-
-[Install]
-WantedBy=default.target
diff --git a/telegram-notifier/telegram-notifier.sh b/telegram-notifier/telegram-notifier.sh
@@ -1,61 +0,0 @@
-#!/usr/bin/env bash
-
-POLLTIME=30
-TIMEOUT=25
-REPLACEID=0 # initial value should be 0
-
-function check_telegram {
- telegram-cli --disable-colors \
- --exec dialog_list | \
- grep -E "[1-9][0-9]* unread"
-}
-
-function kill_tgc {
- sleep $1
- if [[ ! -z $(pidof telegram-cli) ]]; then
- pkill telegram-cli
- fi
-}
-
-function notify_telegram {
- gdbus call --session \
- --dest=org.freedesktop.Notifications \
- --object-path=/org/freedesktop/Notifications \
- --method=org.freedesktop.Notifications.Notify \
- "Telegram" $2 "telegram" "Telegram" "$1" \
- '[]' '{"category": <"im.received">, "desktop-entry": <"telegram">}' \
- 3000
- echo 1 > /sys/devices/platform/leds/leds/pinephone\:blue/brightness
-}
-
-function unnotify_tg {
- gdbus call --session \
- --dest=org.freedesktop.Notifications \
- --object-path=/org/freedesktop/Notifications \
- --method=org.freedesktop.Notifications.CloseNotification \
- $1
- echo 0 > /sys/devices/platform/leds/leds/pinephone\:blue/brightness
-}
-
-while :; do
-
- if [[ -z $(pidof telegram-desktop) ]]; then
-
- # kill after some time
- kill_tgc $TIMEOUT &
-
- UNREADMSG=$(check_telegram)
-
- if [[ ! -z "$UNREADMSG" ]]; then
- REPLACEID=$(notify_telegram "$UNREADMSG" "$REPLACEID" | sed -e 's/^.*\s//' -e 's/[^0-9]//g')
- else
- unnotify_tg $REPLACEID
- REPLACEID=0
- fi
- fi
-
- sleep $POLLTIME
-
-done
-
-# EOF