Hacker News new | past | comments | ask | show | jobs | submit login
AnyBar: OS X menubar status indicator (github.com/tonsky)
296 points by tosh on Nov 27, 2016 | hide | past | favorite | 63 comments



I'll be that guy on this thread that points out Hammerspoon. It's an OS X automation tool that replaces pretty much every OS X 'tweak' style application out there. http://www.hammerspoon.org/go/#simplemenubar

I think it's the best of these type of projects, and would love to see more people using it / developing and sharing scripts.


I hadn't heard of Hammerspoon before your reply, but man I'm glad you posted. This nails a need of mine and looks very useful overall. Thanks!


And I will be that guy on this thread pointing out Keyboard Maestro ; https://www.keyboardmaestro.com/main/

One thing i couldn't replicate yet in hammerspoon (among other things) is clicking: https://wiki.keyboardmaestro.com/action/Find_Image_on_Screen incredibly useful


What is an example of something you would use that feature for?


I use it to (random incomplete list):

  - switch recipients in Franz.app
  - click on menubar items
  - import current page into devonthink (requires a click on  a toolbar item to start the automation)
  - toggle flux (click on menubar item and go down etc)
  - adding tags in delibar (click on the Nth suggested tag)
  - click on toolbar items  in all possible apps when there is no keyboard shortcut/menu item available


Care to share your implementation of your favorite feature? I'm finding it hard to picture what the workflow/result will be like.


Well for one I do use the Caffeine feature that is shown in the section of the Getting Started guide I linked to. That replaced the actual Caffeine app. I have a timer running reminding me to take breaks every so often, that replaced Time Out. I have it auto-detect when I plug into my keyboard at home, and when I do it turns on my bluetooth to pair with my mouse, when I unplug, it turns off the bluetooth. This prevents the annoying issue of my mouse constantly connecting/disconnecting when I'm using my computer in a different room. I have it watching wifi events and automatically setting my volume to 0 when I leave my home wifi network, to prevent any accidental sound blares when I open my laptop in a meeting. Finally I have it bound to some custom hot keys to move/resize my windows around my external monitors. That function replaces the zillion window management apps out there.


> bound to some custom hot keys to move/resize my windows around my external monitors

iTerm2's hotkey is pretty terrible in my opinion. I've bound this function to make it work for me:

    function iTermHotkeyHandler()
      local iterm = hs.application.get('iTerm2')
      if (iterm) then
        local window = iterm:mainWindow()
        if not window then
          if iterm:selectMenuItem('New Window') then
            window = iterm:mainWindow()
          end
          return
        end
        if iterm:isFrontmost() then
          iterm:hide()
        else
          window:focus()
        end
      end
    end
    hs.hotkey.bind('cmd', 'space', iTermHotkeyHandler)
*me: I really should put these in some gist somewhere.


What don't you like about iTerm's show/hide function?


Hotkey windows do not show up in cmd+tab switcher. It's annoying if you activate the hotkey with cmd+space, press cmd+tab to go to previous window, and instinctively press cmd+tab hoping to get back to the terminal window. But that doesn't happen.


OK I understand what you mean. I've never found that to be a problem for me but I'm glad you were able to come up with a solution.


Would you mind filing a bug? The next version is focused on hotkey window improvements and this is very easy to fix. I'm away from my machine now or I'd do it myself. Thanks! ITerm2.com/bugs


If one likes being cheap, it's fun to mute Spotify if there's an Ad. Yeah...

    function muteSpotifyOnAd()
      if (hs.spotify.isRunning()) then
        if (hs.spotify.getCurrentTrack():lower() == 'spotify') then
          hs.spotify.setVolume(0)
        else
          hs.spotify.setVolume(100)
        end
      end
    end
    hs.timer.doEvery(10, muteSpotifyOnAd)


Doesn't spotify pause the ad if the volume is zero? It does for me.


No thanks, one likes earning a few cents from their published music.


Spotify still gets paid by the advertiser, and so does the artist.

It’s like switching TV channels when the ad plays.

In analog media, close to no one ever listened to / watched ads, due to exactly that – many VHS recorders would even automatically skip them.


> close to no one ever listened to / watched ads

I can still sing jingles I learned from watching TV ads in the 70s.


Nice one!


- A scratch pad window that appears on Hyper-S. It appends stuff to my scratch.txt.

- Hyper-1 through 5 to defer tasks in OmniFocus (calls out to an external script).

- Hyper-W to lock my screen.

- Hyper-M to mute skype microphone.

- Hyper-[C,T,X,F] to focus Chrome, TaskPaper, nvAlt and iTerm.


This looks really flexible, thanks for sharing.


Huh, it's like someone wrote an app that's the non-WM part of Awesome WM for OSX. Never thought I'd see that.


Looks really interesting, thanks. Does anyone know if there is anything similar to Hammerspoon out there?


> Does anyone know if there is anything similar to Hammerspoon out there?

Did you forget to include some extra constraint? As written, it looks like the answer to your question is "Yes, Hammerspoon."


Sorry, I realize that is unclear. What I was getting at is just if there are any other similar scripting/automation apps out there, perhaps with a different scripting language or other application integrations. I am a newbie in the automation space so I was wondering what other types of apps people may be using.


You may be interested in AppleScript or AutoHotKey.


Hammerspoon is forked from mjolnir

https://github.com/sdegutis/mjolnir


Bitbar feels much better imo and allowing not just dots - any stuff

https://github.com/matryer/bitbar


My BitBar script to display my current free drive space:

    #!/bin/bash
    df -h | awk '{print $4}' | head -n2 | tail -n1
(There has to be a neater way to do this...)


There is, of course. :)

    df -h | awk 'NR==2 {print $4}'


Thanks :)


+1 for Bitbar. Great tool, capable of displaying any console output in your menubar, so really easy to script in any language.


Bitbar rules. Currently use it to monitor CloudFormation runs on Amazon Web Services, and active turns on two different play-by-web board game sites.


I can't access the plugins on their main page. When I click nothing happens.


Looks like the plugins-page is actually the main page. You can choose some category from the list on the left.


I created a fork of AnyBar with added support for specifying an icon id for any icon from icons8.com and the status icon will change to it. https://github.com/niklasberglund/AnyBar-icons

Just now quickly whipped it together. Needs improvement(error handling and asynchronous downloading) and packages.

HN submission: https://news.ycombinator.com/item?id=13051347


I woulde like to point out the awesome PowerPro for Windows, something like an Swiss army knife of desktop automation in Windows --that seems to be under active development: http://powerpro.cresadu.com/xfeatures.htm


Never was the cultural differences between the windows and OSX platforms more striking than when looking at the PowerPro page http://powerpro.cresadu.com/xfeatures.htm and the HammerSpoon page http://www.hammerspoon.org/


Well the PowerPro website was done nearly 20 years ago, while the HammerSpoon one two years ago, so that's mostly where the difference comes from. Also it seems the PowerPro website makes more sense if viewed on a good old 1024x768 resolution.


This. PowerPro is an amazing tool, although somewhat esoteric. What surprises me is that successive Windows releases have not ended making the development impossible. I submitted a pair of plugins more than 10 years ago. I've been surprised to see development is still active, and for what I understand is pretty equivalent to Hammerspoon, including window management, shortcuts, menubars & desktop scripting support.


How did you come to the conclusion that one website represents an entire culture of millions of developers?


Is there anything similar for Linux? Closest I can find is https://github.com/abgoyal/ShellToolsApplet



There's lots of these due to the plethora of minimalist tiling window managers demanding simple, scriptable info displays.

I use dzen2: https://github.com/robm/dzen

Xmobar is another popular one: http://projects.haskell.org/xmobar


This https://github.com/LemonBoy/bar and a few hundreds of its clone and frameworks.

I recommand getting the polybar clone by jaagr

https://github.com/jaagr/polybar



Does anyone think this could be used to query the desktop Slack app to mirror the information in the dock icon, i.e. "no messages", "messages", "direct messages"?


Unread status is managed remotely (sync'd between devices), so you should be able to query it with an API like https://api.slack.com/methods/channels.history

I wouldn't want such a distraction on screen at all time though.


Great single-purpose tool that does exactly what it advertises. I found AnyBar when searching for a programable menubar indicator. I use it at the end of a particle.io -> ifttt -> node/express/socket.io -> go-lang middleware -> AnyBar pipeline so I don't have to get up to check the only single occupancy restroom at the office.


I like Bitbar more. It gives you direct text output in the bar, and extra lines when clicked..


Thank you for this! Simple and small. I use bitbar and like it very much, but this is a nice add on. I'm all in. Keep developing.


My absolute favorite part of this is exposing controls as a localhost tcp listener, making it easy to control from any tool.


And -- incidentally -- any other computer on your network.

But hey, security schemurity.


Listening on 127.0.0.1 will not make it available it in the network.


This app is not listening on 127.0.0.1 — it binds to all interfaces (and on both IPv4 and IPv6 too), and the parent's comment is completely valid. Anyone who can get a UDP packet to your machine can control this.

  AnyBar  32770 ---   14u    IPv4 0x----------------       0t0      UDP *:1738
  AnyBar  32770 ---   15u    IPv6 0x----------------       0t0      UDP *:1738
(The `nc` command in the example is directed at localhost, but that doesn't imply that the app is bound to localhost only, just that it's bound to at least that.)

Unix sockets are a better fit for this sort of thing, as they can be by default restricted to your user, and optionally opened up to others. (i.e., Unix sockets are authenticated) You can always do both (implement Unix sockets and Internet sockets).

Even binding to localhost in general is not completely safe, if a webpage or other apps can be fooled into making the right request. (I think UDP is safe here, but who knows.)


I'm curious why UDP and not just a small HTTP server? Honestly the overhead is tiny particularly in this use case.


I believe it’s still easier to write a string to a socket than do a full-blown HTTP request. It was designed to be accessible from _anywhere_: bash scripts, build tools plugins, etc. To me single UDP packed seemed like a lowest common denominator


This looks super handy for having a simple status!

Out of curiosity, anyone know what the hammer and sickle icon is for in the screenshot?

*edit for grammar


It’s a keyboard layout indicator (RU/EN). I’m using non-standard layout http://ilyabirman.ru/projects/typography-layout/


This is neat, but the complete lack of access control (UDP) just doesn't seem prudent in 2016.


I assume it binds to the loop back interface so that other hosts can't send messages. Regardless UDP interface does seem odd for this sort of tool.

Edit: nope. It listens on all interfaces. At least an attack can only maliciously change your menubar colour.


Well, assuming the syntax for calling local files isn't breakable by using "../square" to open executables with JPEG extensions too... ;)


I just started reading the code. I don't write Objective-C, but it looks to me as though it will have some vulnerabilities with how it opens images for the dots (but maybe its some sort of resource opening thing that doesn't have the usual path escape vulnerabilities).


I think you shouldn’t open random UDP ports to outside world in the first place




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: