bitbar-github-notifications
An alternative to the official BitBar GitHub notifications plugin, re-written in JavaScript because I understand it and wanted to make some opinionated changes.
Prerequisites
To set up, you will need:
- BitBar
- Node.js (12 or later)
- A GitHub personal access token
- The location of your BitBar plugin directory.
- The location of your Node executable (
which node
).
Installation
- Clone this repository somewhere on your Mac that you'll have permission to access from your BitBar plugin directory. Make note of the path.
cd
into the directory you created in the previous step and runnpm ci
to install dependencies.- Create a new
.js
file in your BitBar directory, following BitBar's conventions for specifying the desired refresh time. For example,github-notifications.30s.js
will refresh every 30 seconds. - Populate the file with one of the below examples, taking care to update the path to your Node executable, the path to where you cloned this repository, and your personal access token.
- Run
chmod +x filename.js
to make sure BitBar will have permissions to run this file.
Example plugin
Basic
#!/usr/bin/env /path/to/your/node/executable
const plugin = require("path/to/bitbar-github-notifications");
plugin({
token: "your GitHub token",
});
With options
#!/usr/bin/env /path/to/your/node/executable
const plugin = require("path/to/bitbar-github-notifications");
plugin({
token: "your GitHub token",
icon: "mark-github", // Use the GitHub favicon
filter: (item) => {
// Don't show PRs that bump dependency versions
return !item.bitbar.text.includes("Bump");
},
});
Options
token
(required): Your GitHub personal access token.icon
: The octicon to use for the menu bar icon. Default: octoface.filter
: An optional callback function to filter results. Receives an object containingbitbar
(data passed to the bitbar package) as well as any API data received along the way (potentiallynotification
,thread
andcomment
). Returnfalse
to remove a notification from the listing. (Note that "mark all as read" will mark all notifications as read, filtered or otherwise.)group
: If true, notifications are grouped by repository. Default:true
apiRoot
: The GitHub API root path. Default:https://api.github.com/
inboxHref
: Location of the Notification inbox. Default:https://github.com/notifications