cfg/.config/i3blocks/github
Knut Ahlers 170fa1a9b9
Load env to set VAULT_ADDR
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2019-01-18 00:28:45 +01:00

24 lines
592 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
[ -f ${HOME}/.config/i3blocks/.env ] && source ${HOME}/.config/i3blocks/.env
# 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}"