2019-01-18 00:20:59 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2019-01-19 15:00:35 +01:00
|
|
|
# In case we got a click, open the notifications page
|
2019-01-28 18:12:45 +01:00
|
|
|
[ -n "${BLOCK_BUTTON:-}" ] && xdg-open "https://github.com/notifications" >/dev/null 2>&1
|
2019-01-19 15:00:35 +01:00
|
|
|
|
2019-01-18 00:20:59 +01:00
|
|
|
# Get token from vault
|
|
|
|
gh_token=$(vault read -field=token secret/private/github/notifications)
|
|
|
|
[ -z "${gh_token}" ] && exit 1
|
|
|
|
|
|
|
|
# Get unread notifications (capped, no pagination!)
|
|
|
|
count=$(curl -su "api:${gh_token}" https://api.github.com/notifications | jq '. | length')
|
|
|
|
|
|
|
|
# No updates: Gray
|
|
|
|
color="#7f7f7f"
|
|
|
|
display_num=""
|
|
|
|
|
|
|
|
# Normal updates: White
|
|
|
|
[ $count -gt 0 ] && {
|
|
|
|
color="#ffffff"
|
|
|
|
display_num=" ${count}"
|
|
|
|
}
|
|
|
|
|
|
|
|
printf '<span color="%s">\ue709%s</span>' "${color}" "${display_num}"
|