oleander / bitbar

A clone of the BitBar app written in Swift 3
MIT License
40 stars 3 forks source link

BitBar BitBar Build Status Slack Status

BitBar (by Mat Ryer - @matryer) lets you put the output from any script/program in your Mac OS X Menu Bar.

Digging deeper:

And finally...

Examples

Example showing the latest Buy and Sell figures for BitCoins:

BitBar Example showing BitCoins plugin

Click to see the full output, and more options:

BitBar Example showing menu open

Example showing your internal and external IP addresses:

BitBar Example showing IP Addresses

Get started

Get the latest version of BitBar. Copy it to your Applications folder and run it - it will ask you to (create and) select a plugins folder, do so.

Browse our plugins to find useful scripts, or write your own.

It's free, so please donate

If you love this, any BitCoin donations are most welcome, to 1DGoNEYAnjE5DqK7y5zMPR4PLU5HLKpLNR or send something useful (Amazon Wishlist).

Installing plugins

Just download the plugin of your choice into your BitBar plugins directory and choose Refresh from one of the BitBar menus.

Configure the refresh time

The refresh time is in the filename of the plugin, following this format:

{name}.{time}.{ext}

For example:

Most plugins will come with a default, but you can change it to anything you like:

Ensure you have execution rights

Ensure the plugin is executable by running chmod +x plugin.sh.

Using symlinks

Because Git will ignore everything in Plugins/Enabled, you can use it to maintain your own plugins directory while still benefitting from tracking (upstream) changes.

Example

cd Plugins/Enabled

# Enable spotify plugin
ln -s ../Music/spotify.10s.sh

# Enable uptime plugin and change update interval to 30 seconds
ln -s ../System/uptime.1m.sh uptime.30s.sh

Then select the Enabled folder in your BitBar preferences.

Resetting Plugin Directory

In case you made the mistake of choosing a directory with thousands of files as the plugin directory and BitBar getting stuck forever, do this from terminal to reset it:

defaults delete com.matryer.BitBar

Contributing

Development

  1. Clone the project git clone https://github.com/matryer/bitbar.git
  2. Ensure you've pod installed on your system using sudo gem install pod
  3. Install dependencies make init within the root of the project
  4. Open in XCode open App/BitBar.xcworkspace

Tests

Make sure you've all dependencies installed on your system by running make setup.

Linting

Release

Thanks

Writing plugins

We're always looking for new plugins, so please send us pull requests if you write anything cool or useful.

Join the conversation with plugin authors and BitBar maintainers on Slack.

Got ideas?

If you've got ideas, or want to report a bug, nip over to our issues page and let us know.

If you want to contribute, please send us a pull request and we'll add it to our repos.

Plugin API

Metadata

To enhance your entry on getbitbar.com, add the following metadata to your source code (usually in comments somewhere):

# <bitbar.title>Title goes here</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Your Name</bitbar.author>
# <bitbar.author.github>your-github-username</bitbar.author.github>
# <bitbar.desc>Short description of what your plugin does.</bitbar.desc>
# <bitbar.image>http://www.hosted-somewhere/pluginimage</bitbar.image>
# <bitbar.dependencies>python,ruby,node</bitbar.dependencies>
# <bitbar.abouturl>http://url-to-about.com/</bitbar.abouturl>
# <bitbar.droptypes>filenames,public.url</bitbar.droptypes>
# <bitbar.demo>--demo</bitbar.demo>

For a real example, see the Cycle text and detail plugin source code.

Useful tips

Examples

One line plugin

#!/bin/bash
date

Multi-line plugin

#!/bin/bash

# the current date and time
date

# the current username
echo $USER

# the current user id
id -u

Multi-line plugin with extra data

#!/bin/bash
echo "One"
echo "Two"
echo "Three"
echo "---"
echo "Four"
echo "Five"
echo "Six"

Multi-line plugin with links and colors

#!/bin/bash
curl -m 1 http://example.com -I >/dev/null 2>&1
[ $? -gt 0 ] && echo "FAIL | color=red" || echo "OK | color=green"
echo "---"
echo "Show Graphs | color=#123def href=http://example.com/graph?foo=bar"
echo "Show KPI Report | color=purple href=http://example.com/report"

Multi-line plugin with fonts and colors

BitBar Example showing colored fonts

#!/bin/zsh
FONT=( 'size=14' 'font=UbuntuMono' )
if ((0)); then echo "DO | $FONT color=orange"
else           echo "DO | $FONT color=cadetblue"
echo "---"
...

Tested languages

Anything that can write to standard out is supported, but here is a list that have been explicitly tested.

  1. Ruby

    1. Status: Working
    2. Output: puts "your string here"
  2. Python2

    1. Status: Working
    2. Output: print "your string here"
  3. Python3

    1. Status: Working
    2. Output: print("your string here")
  4. JavaScript (node)

    1. Status: Working

    2. Caveats: Shebang has to be in the format #!/usr/bin/env /path/to/the/node/executable

    3. Output: console.log("your string here")

    4. Notes:

    5. process.stdout.write doesn't output desired text.

    6. There may be a better way to run JavaScript files.

    7. Tips:

    8. Use the Node.js bitbar module to simplify plugin creation.

  5. CoffeeScript (coffee)

    1. Status: Working

    2. Caveats:

    3. Shebang has to be in the format #!/usr/bin/env /path/to/the/coffee/executable

    4. coffee shebang also had to be modified.

    5. #!/usr/bin/env /path/to/the/node/executable

    6. Output: console.log "your string here"

    7. Notes:

    8. process.stdout.write doesn't output desired text.

    9. There may be a better way to run CoffeeScript files.

  6. Swift (Interpreted)

    1. Status: Working
    2. Output: print("your string here")
  7. Swift (Compiled)

    1. Status: Working

    2. Caveats: You still need a file extension (file.1s.cswift)

    3. Output: print("your string here")

    4. Notes:

    5. To compile a swift file, use: xcrun -sdk macosx swiftc -o file.1s.cswift file.1s.swift

  8. Go (Interpreted)

    1. Status: Working

    2. Caveats:

    3. Your script's shebang must be: //usr/env/bin go run $0 $@; exit

    4. go must be in your PATH

    5. Output: Println("your string here")

  9. Go (Compiled)

    1. Status: Working

    2. Caveats: You still need a file extension (file.1s.cgo)

    3. Output: Println("your string here")

    4. Notes

    5. To compile a Go file, use: go build file.1s.go

  10. Lisp

    1. Status: Working
    2. Caveats: lisp/clisp must be in your PATH
    3. Output: (format t "your string here")
  11. Perl5

    1. Status: Working

    2. Output: print "your string here"

    3. Notes

    4. Add -l to shebang to automatic add newline to print function: #!/usr/bin/perl -l

  12. PHP

    1. Status: Working

    2. Output: echo 'your string here'

    3. Notes

    4. Add shebang #!/usr/bin/php

    5. Utilities:

    6. BitBar PHP Formatter - https://github.com/SteveEdson/bitbar-php