Skip to content

Instantly share code, notes, and snippets.

@Fordi
Created April 13, 2026 19:50
Show Gist options
  • Select an option

  • Save Fordi/37029b7331d8c9376e1be749a420eb7b to your computer and use it in GitHub Desktop.

Select an option

Save Fordi/37029b7331d8c9376e1be749a420eb7b to your computer and use it in GitHub Desktop.
Quick script to marshall GitHub notifications to Ubuntu
#!/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")
*/2 * * * * ${HOME}/.local/bin/check-github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment