Add github notification count
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
866004db14
commit
c47fb8ec62
2 changed files with 24 additions and 0 deletions
|
@ -32,6 +32,9 @@ markup=pango
|
||||||
[mpc]
|
[mpc]
|
||||||
interval=5
|
interval=5
|
||||||
|
|
||||||
|
[github]
|
||||||
|
interval=300
|
||||||
|
|
||||||
[arch-update]
|
[arch-update]
|
||||||
interval=600
|
interval=600
|
||||||
|
|
||||||
|
|
21
.config/i3blocks/github
Executable file
21
.config/i3blocks/github
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# 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}"
|
Loading…
Reference in a new issue