How to use bitbar - 5 common examples

To help you get started, we’ve selected a few bitbar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matryer / bitbar-plugins / Tools / PagerDuty / pagerDutyIncidents.30s.js View on Github external
/* jshint esversion: 6 */
'use strict';
const fetch = require('node-fetch');
const ta = require('time-ago')();
const bitbar = require('bitbar');

const cfg = require('home-config').load('.bitbarrc');

if (!cfg.pagerdutyincidents['api.endpoint'] || !cfg.pagerdutyincidents['api.token']) {
  const json = [];

  json.push({
    text: 'Config Needed',
    dropdown: false,
  },
  bitbar.sep, {
    text: 'Add to your .bitbarrc config file on your',
  }, {
    text: 'home directory the following information:',
  },
  bitbar.sep, {
    text: '[pagerdutyincidents]',
  }, {
    text: 'api.endpoint=https://',
  }, {
    text: 'api.token={your-token}',
  });

  bitbar(json);
  process.exit();
}
github robertbenjamin / bit-bus / index.js View on Github external
// v1.0
// Robert Benjamin
// robertbenjamin
// A BitBar menubar app for seeing when the next bus arrives at my work.
// http://i.imgur.com/zjuQRQF.png
// node,superagent,momentjs
// https://github.com/robertbenjamin/bit-bus

const bitbar = require('bitbar');
const request = require('superagent');
const moment = require('moment');
const busAPIKey = require('./src/API_KEY.js') || 'TEST';

let busStop = 18620;
let busAPI = `http://api.pugetsound.onebusaway.org/api/where/arrivals-and-departures-for-stop/1_${busStop}.json?key=${busAPIKey}&minutesAfter=70`;
let menuColor = bitbar.darkMode ? 'white' : 'black';
let warningColor = '#ff4136';

request
.get(busAPI)
.end((err, res) => {
  if (err || !res.ok) bitbar([{ text: ':bus: no internet :(', color: warningColor }]);

  let response = JSON.parse(res.text);
  let trips = response.data.entry.arrivalsAndDepartures;

  if (trips.length === 0) {
    bitbar([{ text: ':bus: no more trips', color: warningColor }]);
  } else {
    let myTrips = trips
      .filter(trip => trip.routeShortName === '32')
      .map(trip => {
github robertbenjamin / bit-bus / index.js View on Github external
let newTrip = {};

        newTrip.scheduledArrival = moment(trip.scheduledArrivalTime).fromNow();
        if (trip.predictedArrivalTime) newTrip.predictedArrival = moment(trip.predictedArrivalTime).fromNow();

        return newTrip;
      });

    let menu = [];

    menu.push({
      text: `:bus: ${myTrips[0].predictedArrival || myTrips[0].scheduledArrival}`,
      color: myTrips[0].predictedArrival ? menuColor : warningColor
    });

    menu.push(bitbar.sep);

    myTrips.slice(1).forEach(trip => {
      menu.push({
        text: `:point_right: ${trip.predictedArrival || trip.scheduledArrival}`,
        color: trip.predictedArrival ? menuColor : warningColor
      })
    });

    bitbar(menu);
  }
});
github matryer / bitbar-plugins / Tools / PagerDuty / pagerDutyIncidents.30s.js View on Github external
color: config.colors.regularText,
        }, {
          text: `Urgency\t\t: ${incident.urgency}`,
          color: config.colors.regularText,
        }, {
          text: `Escalations\t: ${incident.number_of_escalations}`,
          color: config.colors.regularText,
        });
      });

      json.push({
        text: `${serviceIncidents[prop].name} (${serviceIncidents[prop].incidents.length})`,
        href: serviceIncidents[prop].html_url,
        submenu: incidents,
      },
      bitbar.sep);
    });
  } else {
github matryer / bitbar-plugins / Tools / PagerDuty / pagerDutyIncidents.30s.js View on Github external
.then((obj) => {
  const json = [];
  const serviceIncidents = obj.serviceIncidents;

  json.push({
    text: `[${obj.total}]`,
    dropdown: false,
    templateImage: config.icon.inactive,
    size: 8,
  },
  bitbar.sep);

  if (Object.keys(serviceIncidents).length) {
    Object.keys(serviceIncidents).forEach((prop) => {
      const incidents = [];

      serviceIncidents[prop].incidents.forEach((incident) => {
        const assignedTo = [];

        incident.assigned_to.forEach((user) => {
          assignedTo.push({
            text: `${user.object.name}, ${ta.ago(new Date(Date.parse(user.at)))}`,
            href: user.object.html_url,
            color: config.colors.regularText,
          }, {
            text: user.object.email,
            alternate: true,

bitbar

Simplifies BitBar app plugin creation

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular bitbar functions