Git Product home page Git Product logo

bitbar's Introduction

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}
  • name - The name of the file
  • time - The refresh rate (see below)
  • ext - The file extension

For example:

  • date.1m.sh would refresh every minute.

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

  • 10s - ten seconds
  • 1m - one minute
  • 2h - two hours
  • 1d - a day

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.

  • Run the test suit once: make test
  • Run the suit every time a file changes: make watch
  • Run a specific test: make test class=PropertyTest or make watch class=PropertyTest

Linting

  • make lint will display all linting errors
  • make fix will fix linting errors

Release

  • Release: make release

Thanks

  • Special thanks to @muhqu and @tylerb for all their help (see commit history for details)
  • Thanks to Chris Ryer for the app logo - and to @mazondo for the original
  • Thanks for all our plugin contributors who have come up with some pretty genius things

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.

  • Ensure the plugin is executable
  • Be sure to include appropriate Metadata to enhance the plugin's entry on getbitbar.com

Plugin API

  • To write a plugin, just write some form of executable script that outputs to the standard output.

  • Multiple lines will be cycled through over and over.

  • If your output contains a line consisting only of ---, the lines below it will appear in the dropdown for that plugin, but won't appear in the menu bar itself.

  • Lines beginning with -- will appear in submenus.

  • Output ~~~ from long running scripts to render everything above it and since the last ~~~ (example).

  • Your lines might contain | to separate the title from other parameters, such as...

    • href=.. to make the item clickable
    • color=.. to change their text color. eg. color=red or color=#ff0000
    • font=.. to change their text font. eg. font=UbuntuMono-Bold
    • size=.. to change their text size. eg. size=12
    • bash=.. to make the item run a given script terminal with your script e.g. bash=/Users/user/BitBar_Plugins/scripts/nginx.restart.sh if there are spaces in the file path you will need quotes e.g. bash="/Users/user/BitBar Plugins/scripts/nginx.restart.sh"
    • param1= to specify arguments to the script. additional params like this param2=foo param3=bar full example bash="/Users/user/BitBar_Plugins/scripts/nginx.restart.sh" param1=--verbose assuming that nginx.restart.sh is executable or bash=/usr/bin/ruby param1=/Users/user/rubyscript.rb param2=arg1 param3=arg2 if script is not executable
    • terminal=.. start bash script without opening Terminal. true or false
    • refresh=.. to make the item refresh the plugin it belongs to
    • dropdown=.. May be set to true or false. If false, the line will only appear and cycle in the status bar but not in the dropdown
    • length=.. to truncate the line to the specified number of characters. A will be added to any truncated strings, as well as a tooltip displaying the full string. eg. length=10
    • trim=.. whether to trim leading/trailing whitespace from the title. true or false (defaults to true)
    • alternate=true to mark a line as an alternate to the previous one for when the Option key is pressed in the dropdown
    • templateImage=.. set an image for this item. The image data must be passed as base64 encoded string or URL and should consist of only black and clear pixels. The alpha channel in the image can be used to adjust the opacity of black content, however. This is the recommended way to set an image for the statusbar. Use a 144 DPI resolution to support Retina displays. The imageformat can be any of the formats supported by Mac OS X
    • image=.. set an image for this item. The image data must be passed as base64 encoded string or URL. Use a 144 DPI resolution to support Retina displays. The imageformat can be any of the formats supported by Mac OS X
    • emojize=false will disable parsing of github style :mushroom: into 🍄
    • ansi=false turns off parsing of ANSI codes.
    • checked=true for a checkmark

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>
  • The comment characters can be anything - use what is suitable for your language
  • bitbar.title - The title of the plugin
  • bitbar.version - The version of the plugin (start with v1.0)
  • bitbar.author - Your name
  • bitbar.author.github - Your github username (without @)
  • bitbar.desc - A short description of what your plugin does
  • bitbar.image - A hosted image showing a preview of your plugin (ideally open)
  • bitbar.dependencies - Comma separated list of dependencies
  • bitbar.abouturl - Absolute URL to about information
  • bitbar.droptypes - Uniform type identifiers or filenames, comma separated. Plugin is executed with arguments -type and the dropped item(s) (example)
  • bitbar.demo - Whitespace separated arguments to execute plugin with in demo mode (i.e. when saving a screenshot)

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

Useful tips

  • If you're writing scripts, ensure it has a shebang at the top.
  • You can add to PATH by including something like export PATH='/usr/local/bin:/usr/bin:$PATH' in your plugin script.
  • You can use emoji in the output (find an example in the Music/vox Plugin).
  • If your bash script generates text in another language, set the LANG variable with: export LANG="es_ES.UTF-8" (for Spanish) to show the text in correct format.
  • If you want to call the plugin script for action, you can use bash=$0
  • If your plugin should support Retina displays, export your icon at 36x36 with a resolution of 144 DPI (see this issue for a more thorough explanation).

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"
  • Only One, Two and Three will appear in the top bar
  • Clicking the plugin menu item will show all lines

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

  2. Status: Working

  3. Output: puts "your string here"

  4. Python2

  5. Status: Working

  6. Output: print "your string here"

  7. Python3

  8. Status: Working

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

  10. JavaScript (node)

  11. Status: Working

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

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

  14. Notes:

1. `process.stdout.write` doesn't output desired text.
2. There may be a better way to run JavaScript files.
  1. Tips:
1. Use the Node.js [`bitbar` module](https://github.com/sindresorhus/bitbar) to simplify plugin creation.
  1. CoffeeScript (coffee)

  2. Status: Working

  3. Caveats:

1. Shebang has to be in the format `#!/usr/bin/env /path/to/the/coffee/executable`
2. `coffee` shebang also had to be modified.
3. `#!/usr/bin/env /path/to/the/node/executable`
  1. Output: console.log "your string here"

  2. Notes:

1. `process.stdout.write` doesn't output desired text.
2. There may be a better way to run CoffeeScript files.
  1. Swift (Interpreted)

  2. Status: Working

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

  4. Swift (Compiled)

  5. Status: Working

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

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

  8. Notes:

1. To compile a swift file, use: `xcrun -sdk macosx swiftc -o file.1s.cswift file.1s.swift`
  1. Go (Interpreted)

  2. Status: Working

  3. Caveats:

1. Your script's shebang must be: `//usr/env/bin go run $0 $@; exit`
2. `go` must be in your `PATH`
  1. Output: Println("your string here")

  2. Go (Compiled)

  3. Status: Working

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

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

  6. Notes

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

  2. Status: Working

  3. Caveats: lisp/clisp must be in your PATH

  4. Output: (format t "your string here")

  5. Perl5

  6. Status: Working

  7. Output: print "your string here"

  8. Notes

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

  10. PHP

  11. Status: Working

  12. Output: echo 'your string here'

  13. Notes

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

  15. Utilities:

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

bitbar's People

Contributors

alexandregz avatar daturkel avatar dlajarretie avatar gautamkrishnar avatar ibutra avatar iosdeveloper avatar jessor avatar joncse avatar jtokoph avatar kamenevn avatar ksuther avatar maio avatar manojlds avatar matryer avatar matzfan avatar mralexgray avatar muhqu avatar nlassaux avatar oleander avatar raemondbw avatar seripap avatar sg-s avatar steveedson avatar taylorzane avatar tomkinsc avatar tresni avatar trungdq88 avatar vogonistic avatar willyt avatar zackkatz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bitbar's Issues

Base64 image is not shown

I have a script that looks like this

#!/bin/bash

# <bitbar.title>develop-pipeline</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Daniel Satanik</bitbar.author>
# shellcheck disable=SC2034

pipelineImg=$(curl -s https://gitlab.example.com/group/project/badges/branch/pipeline.svg?private_token=<my_private_token>)

if [ "$pipelineImg" == "" ]; then
  pipelineImg=<alternative_base64_encoded_image>
else
  pipelineImg=$(echo $pipelineImg | /usr/local/bin/rsvg-convert -h 12 | base64)
fi
printf "%s | image=%s\n" "" "$pipelineImg"
echo "---"
echo "Refresh... | refresh=true"

Unfortunately, unlike in the original app the images are not showing, something I do wrong?
As I said it works in the original BitBar, and I just switched because your fork seems to remember locations in the menubar and more up-to-date

Distro version?

I guess you would do this when you consider your main vision "stable"?

BitBar doesn't start

mac OS High Sierra
10.13.3

Double click the app after copying to Applications, fails, no error message.

Starting the app via the command line, yields the following error.

$ /Applications/BitBar.app/Contents/MacOS/BitBar ; exit;
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Applications/BitBar.app/Contents/Frameworks/Configs.framework/Versions/A/Configs
  Reason: image not found
Abort trap: 6

Do not show ... when plugin prints nothing.

Hi!

I'm using the "Show Time machine Progress" plugin from getbitbar.com. This plugin shows the status of Time Machine backups when they are in progress.
With official Bitbar, the menu item is hidden when there is no backup in progress because it outputs nothing when no backup is in progress, however with your fork, it shows "..." in the menu bar.

bitbar

Is it possible to not show the item, like the old Bitbar did? Thanks!

Crashes on 10.12 hackintosh

When running on my 10.12 hackintosh, I get the following error : Illegal instruction: 4.

Running the original bitbar doesn't show this issue. A cursory glance online seems to say that the compiler is using a too new instruction set. Is there a way to solve this issue ?

Breaks when plugin path contains spaces

When the plugin folder path is ~/Script and such/Bitbar/ it just displays "Script or subscript not found, verify the file path". However, when the folder is just named Scripts it works fine

Do not override color in menu bar

The current implementation uses a default gray color for the menu bar. This overrides the users predefined color. Only set the color if there isn't any preexisting.

Fine tune support for config files

Example

refreshOnWake=true
startOnBoot=true
cycleInterval=10s
font.size=10
font.family=Mono
ignoreFiles=.*,.git
terminalApp=iTerm

[plugin1.10m.sh]
enabled=true
position=1
env.arg1=ABC
env.arg2=DEF

[plugin2.2d.sh]
enabled=true
position=1
env.arg1=ABC
env.arg2=DEF

Broken menu display compared to regular BitBar

BitBarSwift
screen shot 2018-03-10 at 21 58 26

BitBar 1.9.2
screen shot 2018-03-10 at 21 58 56

Console

default	22:06:41.850357 +0000	launchservicesd	CHECKIN:0x0-0x1c0fc0e 88968 com.getbitbar.BitBar
default	22:06:51.870235 +0000	BitBar	LSExceptions shared instance invalidated for timeout.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.