Created
April 13, 2026 19:50
-
-
Save Fordi/37029b7331d8c9376e1be749a420eb7b to your computer and use it in GitHub Desktop.
Quick script to marshall GitHub notifications to Ubuntu
This file contains hidden or 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/bash | |
| TMPDIR="$(mktemp -d)" | |
| function cleanup() { | |
| rm -rf "$TMPDIR" | |
| } | |
| trap cleanup EXIT | |
| gh api /notifications > "$TMPDIR/notifications.json" | |
| if jq -e '.[0] == null' "$TMPDIR/notifications.json" > /dev/null; then | |
| exit | |
| fi | |
| while read -r line; do | |
| reason="$(echo "$line" | jq -r '.reason')" | |
| subject="$(echo "$line" | jq -r '.subject.title')" | |
| type="$(echo "$line" | jq -r '.subject.type')" | |
| id="$(echo "$line" | jq -r '.subject.url' | cut -d / -f 8)" | |
| url="$(echo "$line" | jq -r '.subject.url' | sed 's/api\.//' | sed 's/\/pulls\//\/pull\//' | sed 's/repos\///' )" | |
| repo="$(echo "$line" | jq -r '.repository.full_name')" | |
| ( | |
| RESPONSE="$(notify-send \ | |
| --app-name="$repo" \ | |
| "${reason}: ${subject} #${id}" \ | |
| --action="Open ${url}" | |
| )" | |
| if [[ -n "$RESPONSE" ]]; then | |
| open "$url" | |
| fi | |
| ) & | |
| exit | |
| done < <(jq -rc '.[]' "$TMPDIR/notifications.json") |
This file contains hidden or 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
| */2 * * * * ${HOME}/.local/bin/check-github |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment