Hacker News new | past | comments | ask | show | jobs | submit login
BitBar: put the output from any script/program in your Mac OS X Menu Bar (github.com/matryer)
385 points by trueduke on Jan 5, 2016 | hide | past | favorite | 64 comments



As my way of playing around with what BitBar can do, I created a Spotify script. Until it's merged you can check out the pull request: https://github.com/matryer/bitbar/pull/34

Shows current track name and artist in menu bar. Shows track/artist/album in dropdown along with play/pause/next/previous buttons.

Raw script here: https://raw.githubusercontent.com/jtokoph/bitbar/jtokoph-spo...


Hijacking my own post.

Been having lots of fun playing with BitBar. Just finished a clipboard history plugin: https://github.com/matryer/bitbar/pull/47


Very nice, but none of the multiline bits after the pipe works for me (might be Bitbar rather than your script though).

EDIT: The reason for this is the version installed by brew is 1.2, and that bug was fixed in 1.3.1.



That's fixed it ... just needed to update brew and do a "brew cask install --force bitbar" to update. Now it's working. Cheers!


Awesome tool! I've always wanted to make menubar apps but never wanted to learn Xcode+ObjectiveC.

Related:

Is there no simple way to get the current temperature for location based off of GeoIP using `curl`?

I had to use this monstrosity to get the current temperature:

    #!/bin/bash

    export PATH='/usr/local/bin:$PATH'

    ansiweather -a off -l 'San Francisco' \
      | cut -d '>' -f 2 \
      | cut -d '-' -f1 \
      | awk '{ print $1 $2 }' \
      | tr -d 'C'


You could use OpenWeatherMap's API. Something like this is pure (remove the `&units=imperial` if you prefer Celsius):

    curl -s "http://api.openweathermap.org/data/2.5/weather?zip=$(curl -s ipinfo.io/postal),us&appid=2de143494c0b295cca9337e1e96b00e0&units=imperial" \
      | sed -e 's/\(.*\)temp":\([0-9.]*\),\(.*\)/\2/'
or you could replace the `sed` pipe with a call to `jq`:

    curl really_long_url | jq '.main.temp'


> remove the `&units=imperial` if you prefer Celsius

That would get you Kelvin, use `&units=metric` for Celsius


Good call! I completely forgot the default units were in Kelvin, and not Celsius.


Not curl, but this script may be a worthy replacement? https://raw.githubusercontent.com/grahamg/Practice/master/we...


Looks very similar to: http://sveinbjorn.org/platypus/ (http://sveinbjorn.org/files/manpages/PlatypusDocumentation.h...)

BitBar focuses on just the Menu Bar use case though, and does a more polished job than Platypus.


Also AnyBar, which displays a coloured dot in the menu bar: https://github.com/tonsky/AnyBar

Or TextBar, which is a $3 utility: http://www.richsomerfield.com/apps/



I've been using https://github.com/jaredks/rumps for this sort of thing.


Another vote for rumps.


I just wrote a plugin to allow me to set my Network location (we sit behind a corporate proxy at work) AND my bash proxy settings at the same time.

So when I'm not in the office switching to my "home" profile is just a menu click away.

This has been a long standing dream of mine to automate - so thanks!

EDIT: also it works with emojis, which is handy, here's a screenshot http://imgur.com/CVxchnI


I hope you submitted a pull request!


Sadly it's too bespoke to release, I had all the profile switching scripts written already and have been using them for a few years now. On top of updating environment variables with proxy settings etc, they also update a bunch of configuration files for maven, ssh, stunnel etc via symlinks

All this bitbar thing does is call those existing scripts, very simple, but saves me

a) wondering what profile I have enabled (now in the menubar) b) opening a terminal and typing "update-env (work|home)" (one click switch)


Could also use Hammerspoon (http://www.hammerspoon.org/) for this. It uses Lua but you can invoke processes and modify the toolbar. In addition you can hook into keystrokes, do window management, and all kinds of stuff.


and the upcoming 0.9.44 release will be even more flexible for this sort of use, because the process invoking stuff (http://www.hammerspoon.org/docs/hs.task.html ) will support processes that run indefinitely, so you could do crazy stuff like have a menubar item that shows the most recent line of a log file, or whatever you want :)


Yeah hammerspoon rocks and is very lightweight and easy to use... This simple example shows how powerful it is for automation:

http://www.hammerspoon.org/go/#simplemenubar

  -- Creating a simple menubar item
  -- Lots of Mac utilities place a small icon in the system menubar to display their 
  -- status and let you interact with them. We're going to use two of Hammerspoon's 
  -- extensions to whip up a very simple replacement for the popular utility Caffeine.

  local caffeine = hs.menubar.new()
  function setCaffeineDisplay(state)
      if state then
          caffeine:setTitle("AWAKE")
      else
          caffeine:setTitle("SLEEPY")
      end
  end

  function caffeineClicked()
      setCaffeineDisplay(hs.caffeinate.toggle("displayIdle"))
  end

  if caffeine then
      caffeine:setClickCallback(caffeineClicked)
      setCaffeineDisplay(hs.caffeinate.get("displayIdle"))
  end


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


This should be somewhere in the documentation if it's not already.



It would be good to sumbit a ticket for the original hanging bug as well, if one doesn't already exist.


Would this involve a timeout or maximum plugin count? Something like that? Please do open a ticket.


Ideally, the scanning process would be asynchronous so that the program would remain responsive and you could retarget it within the app.


This is a great idea; looks really practical and easy to extend. Is there a list of more plugins anywhere? There's only a few in the repo: https://github.com/matryer/bitbar/tree/master/Plugins


This reminds me of geektool http://projects.tynsoe.org/en/geektool/ which seems like it may have been abandoned? It was one of my favorite tools.


It doesn’t seem to be abandoned. The latest version of Geektool (3.1.3) seems to have been released in October and even has support for El Capitan¹.

――――――

¹ — http://projects.tynsoe.org/en/geektool/download.php


A bit more modern and customizable alternative is Übersicht. Widgets are created in HTML5 and CoffeScript.

http://tracesof.net/uebersicht/


Last time I checked this tool they didn't support multiple monitors. Is that fixed now?

Also big minus was menu bar icon, such tools don't need one.


I only use one though, so I can't say for sure but judging by their blog posts they offer to choose which monitor Ubersicht runs on, but I believe it can't be displayed on multiple monitors at the same time. That's true about the menubar icon, but it doesn't bother me.


For i3, i3blocks does the same job:

https://github.com/vivien/i3blocks


Why thank you, I use i3 (i love it) and this will be very useful.


And nobody is restricted to shell scripts. Any program that writes to STDOUT will work.


The issue i can see in gnome-shell (on linux) implementations is that long running script can block the UI. Async script execution, on the other hand, exhaust open file resources due to non closed file descriptors. Do OSX tools like this suffer the same problem?


I won't be able to get to tinkering with this for a couple weeks, but if it does what it says it does, I've been wanting almost exactly this for a very long time. Thanks for getting it out there.


I made something quite similar a while ago for Linux (Cinnamon).

https://github.com/abgoyal/ShellToolsApplet http://cinnamon-spices.linuxmint.com/applets/view/136


Sweet. Does anyone happen to know if there is something similar for gnome-based environments on Linux ?


I have been using https://extensions.gnome.org/extension/437/mylauncher/ to execute shell commands, to see output I have just found this: https://extensions.gnome.org/extension/912/command-output/, but I haven't tried it yet.



Conky is great for this sort of thing.


I haven't used conky in a while, but can you interact with it now?

I was checking the plugins and some of them allow clicking on items in the dropdown and having an action execute.

The clipboard history now has code for this.


This is fantastic, I wanted to donate - but do not have a Bitcoin wallet. Any other options?


You're too kind - these words are enough. But if you insist, I do need some socks :) http://amzn.to/1Pd9yOt


I made a Node.js module with a nice API for it to ease plugin creation: https://github.com/sindresorhus/bitbar


I'm missing something. I have it installed. My plugins are executable. I've Reset. I've changed the folder. But BitBar says "No Plugins Found"


Must be a Mac thing. I downloaded the .zip file and the plugins work.


Nice. There are already a couple of programs that do this I think, but maybe use AWS CLI to write a plugin for monitoring ec2 instances' status.


I almost bought TextBar (www.richsomerfield.com). You for saved me $2.99 and 5 minutes of time. I'm disproportionately grateful for this.


Anyone know how to do similar for Xfce or LXDE?


XFCE has an applet called "generic monitor" that can be used for this.


There's also a lightweight menu bar for X11 systems called bar. https://github.com/LemonBoy/bar


Awesome, now I can run quick Python commands and see the output in my XFCE panel: sudo apt-get install xfce4-genmon-plugin Right click panel > Panel > Add New Items > Generic Monitor > Add Right click "(genmon)XXX", > Properties Try this command: python -c "import time;print time.time()" You might set it to run every 10 seconds. You could get results from a webpage or all kinds of things. It supports images, tooltips, progress bar, buttons... This is great! Thanks!


Amazing!!!!! Thanks for this :)


Very nice. Does anyone have entry points to do the same with gnome 3 ?


See this two comments of mine. Perhaps time to study these and make a nice universal, working extension.

https://news.ycombinator.com/item?id=10843704 https://news.ycombinator.com/item?id=10841525


Anyway I can hook up custom keyboard shortcuts to BitBar scripts?


Nice idea - you should raise an issue: https://github.com/matryer/bitbar/issues


Very clever approach, I like the simple text-based format.


This is awesome. Can't wait to see more plugins.


Me too :) We didn't have to wait long - check these out: https://github.com/matryer/bitbar-plugins

Some of them are like full apps in their own right.


Anyone know of a solution like this for KDE Plasma?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: