Last active
December 17, 2022 12:28
-
-
Save rubenhorn/7c065f570e2bb61b8e3ada44ebac4adf to your computer and use it in GitHub Desktop.
Personal Push Notifications
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
#! /bin/sh | |
HOST="ntfy.sh" | |
TOPIC="hh2WuvyfG7dN8tQx8ZxLF8wE" | |
TIMEOUT=10 | |
# Hack to get around issue of output not being piped | |
while true | |
do | |
curl -s $HOST/$TOPIC/json --max-time $TIMEOUT | jq -c 'select(.event == "message")' | while IFS= read -r JSON | |
do | |
TITLE="$(echo $JSON | jq -r '.title')" | |
MESSAGE="$(echo $JSON | jq -r '.message')" | |
notify-send -a "$HOST/$TOPIC" $TITLE $MESSAGE | |
done | |
done |
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
#! /bin/sh | |
HOST="ntfy.sh" | |
TOPIC="my-topic" | |
if [ $# == 1 ] | |
then | |
TITLE="ntfy.sh" | |
MESSAGE="$1" | |
elif [ $# == 2 ] | |
then | |
TITLE="$1" | |
MESSAGE="$2" | |
else | |
echo "Usage: $0 [TITLE] <MESSAGE>" | |
exit 1 | |
fi | |
curl -H "Title:$TITLE" -d "$MESSAGE" $HOST/$TOPIC &> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment