Customized GitHub Notifications for MacOS

Darren Berg
Sep 11 · 3 min read

GitHub has two choices for notifications: email or a small blue dot in the corner of the page. As a developer at Doctolib I get lots of notifications throughout the day, which means either frequent email alerts or keeping a close eye on the blue dot.

I wanted something in the middle, so I wrote a script to generate desktop notifications at a frequency I can choose.

Here’s the repository if you want to skip ahead to the code: https://github.com/darrenberg/github-notifications

Notification Content

The GitHub API has everything we need and we can parse the output with a command-line utility called jq.

Authentication and Password Storage

The easiest way to connect to the GitHub API is by creating a personal access token, which can be scoped to only access notifications.

However, storing this token in my script wouldn’t be very secure, so I used the MacOS Keychain.

Remember to generate a new personal access token if you accidentally post it on Medium

It’s easy to add an entry from Keychain Access and you can retrieve it from the command line with find-generic-password. For more information, check out https://www.netmeister.org/blog/keychain-passwords.html

Desktop Notifications

I used terminal-notifier to create the desktop notification. You can control whether it’s a banner or alert in the MacOS Notification Preferences.

echo 'Piped Message Data!' | terminal-notifier -sound default

The Script!

Simply pass the number of minutes to wait between calls (e.g. ./notify.sh 10 will run every 10 minutes) and it will show you all your unread notifications with a link to GitHub. Or take out the infinite loop and run it as a cron job.

Detailed installation instructions can be found at https://github.com/darrenberg/github-notifications

Conclusion

According to Larry Wall, the original author of the Perl programming language, there are three great virtues of a programmer; Laziness, Impatience and Hubris:

Come be lazy at Doctolib! https://about.doctolib.com/careers/engineering.html

Doctolib

Pour un système de santé plus humain, efficace et connecté

Thanks to Romain Pellerin

Darren Berg

Written by

Doctolib

Doctolib

Pour un système de santé plus humain, efficace et connecté

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade