Skip to content

Instantly share code, notes, and snippets.

@rubenhorn
Last active December 17, 2022 12:28

Revisions

  1. rubenhorn revised this gist Dec 17, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion get-notified
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,6 @@ while true
    do
    curl -s $HOST/$TOPIC/json --max-time $TIMEOUT | jq -c 'select(.event == "message")' | while IFS= read -r JSON
    do
    echo $JSON | jq
    TITLE="$(echo $JSON | jq -r '.title')"
    MESSAGE="$(echo $JSON | jq -r '.message')"
    notify-send -a "$HOST/$TOPIC" $TITLE $MESSAGE
  2. rubenhorn created this gist Dec 17, 2022.
    17 changes: 17 additions & 0 deletions get-notified
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #! /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
    echo $JSON | jq
    TITLE="$(echo $JSON | jq -r '.title')"
    MESSAGE="$(echo $JSON | jq -r '.message')"
    notify-send -a "$HOST/$TOPIC" $TITLE $MESSAGE
    done
    done
    19 changes: 19 additions & 0 deletions push
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #! /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