Last active
January 21, 2025 15:30
-
-
Save theKAKAN/d70feb19fe10a3121812a538eeabf4e2 to your computer and use it in GitHub Desktop.
Checks for MQTT subbed-topic in Termux or linux and sends push notifications on receiving a message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
IP="10.0.0.1" #Change to IP of server | |
TOPIC="torrent/finished" # Change to your liking | |
VERSION="mqttv5" | |
if [ -n "$(command -v mosquitto_sub)" ]; then | |
echo "Found mosquitto" | |
if [ "$( uname )" == "Linux" ]; then | |
if [ -n "$( command -v termux-notification )" ]; then | |
echo "Running in termux" | |
mosquitto_sub -h "$IP" -V "$VERSION" -t "$TOPIC" | while read OUTPUT; do termux-notification -c "$OUTPUT"; done | |
elif [ -n "$( command -v notify-send )" ]; then | |
echo "Using notify-send" | |
mosquitto_sub -h "$IP" -V "$VERSION" -t "$TOPIC" | while read OUTPUT; do notify-send "$TOPIC" "$OUTPUT"; done | |
else | |
echo "Install a compatible notification service." | |
fi | |
else | |
echo "You must run a compatible OS" | |
fi | |
else | |
echo "Mosquitto not found" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment