13

I need a menu-bar app* which will show me the output of a terminal command, and run that Terminal command every 60s or so.

Or I need a menu-bar app which will read the contents of a file, and update whenever that file is updated.

(The output would be no more than 3 or 4 digits)

Are there any such apps?

* neither the Dock nor the Desktop are workable alternatives. Needs to be the menu bar.

Update 2014-06-16: The answer from Jun 9 '12 at 2:15 did not end up working for me after all, so I'm still looking for a solution.

2020-04-04

I forgot all about having asked this question. For the past several years I have been using TextBar which is the perfect solution that I had always been looking for.

See also:

TextBar Puts Your Text into the Menu Bar - MacStories

8
  • 3
    See GeekTool! projects.tynsoe.org/en/geektool
    – user588
    Jun 9, 2012 at 2:48
  • GeekTool = Desktop, not menu bar.
    – TJ Luoma
    Jun 9, 2012 at 3:34
  • 1
    You can position output wherever you want it, including the menubar. 3 or 4 digits, small font, two lines, could fit left of apple or right of spotlight icons.
    – user588
    Jun 9, 2012 at 3:56
  • I want this information to be visible by glancing at the menu bar, not by me having to go into the menu bar to look at it. Like a clock or Disk Alarm,
    – TJ Luoma
    Jun 15, 2012 at 11:45
  • 1
    Yup. GeekTool output floats on top of everything. I think the ruby-driven solution is better, but this would work if your output is not very large. If you need more space add a menu item you don't want to see (volume control?) and have the GeekTool output cover it with a non-transparent background.
    – user588
    Jun 15, 2012 at 12:31

5 Answers 5

11
#!/usr/bin/env ruby

require "osx/cocoa"
include OSX

app = NSApplication.sharedApplication 
statusitem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength)
while true
    statusitem.setTitle(rand(999))
    sleep 1
end
app.run

(If anyone who actually knows Cocoa wants to improve this, feel free to edit.) I more or less just copied the script from taw's blog: Personal experience points and OSX menulets, which was mentioned in display - Is there a way to have AppleScript output displayed in the menubar? - Apple.

2
  • Wow, that's pretty awesome. For some reason it works great with rand but doesn't update my command (I get the output of the first time it runs, but it never changes after that), but it's a great starting point. Makes me wish I knew Ruby!
    – TJ Luoma
    Jun 9, 2012 at 17:56
  • @TJLuoma The original script used an NSTimer to update the status item, but I couldn't figure it out. (If someone can, edits are still welcome.)
    – Lri
    Jun 10, 2012 at 4:17
6
+100

Here is the solution in python.
Install rumps framework (linked repository has patch for OS X 10.9.3)
sudo pip install git+https://github.com/tito/rumps

You might need to adjust $PYTHONPATH to include pyobjc (Foundation)
export PYTHONPATH=/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Adjust the following code for your needs:

#!/usr/bin/env python
import rumps
import os
import threading


class AwesomeStatusBarApp(rumps.App):
    def __init__(self):
        super(AwesomeStatusBarApp, self).__init__("Awesome App", "Title")
        tail(self)


def tail(self):
    threading.Timer(5, tail, [self, ]).start()
    self.title = os.popen("tail -1 /var/log/system.log").read()[0:-1][0:50]

AwesomeStatusBarApp().run()

Do not forget to limit the length of the string ([0:50]) (or OS X will remove it in favor of menus if they both don't fit), and get rid of the newline in the end ([0:-1])

enter image description here

3
  • Thanks! This shows an app in the dock as well as the menu bar. Any idea how to have it show only in the menu bar?
    – TJ Luoma
    Jun 17, 2014 at 18:31
  • You can use something like Platypus to create an app from your script and adjust it's .plist to not show in dock.
    – Sergei
    Jun 21, 2014 at 7:53
  • Thanks! I was hoping to find something a little more… user friendly? Plug + play? Something. But this is 100% better than what I had, and I appreciate the time and effort to answer it.
    – TJ Luoma
    Jun 24, 2014 at 22:30
3

There is another recent open source alternative called BitBar (MIT License), which appears very similar to "TextBar" and "ShellWrangler" and amazes through its simplicity.

You can execute scripts at any time interval that is encoded in the script file name (e.g. my_script.60s.py) and it can execute any script you can also execute in your Terminal.

3
  • 1
    I like its simplicity, too, as you just put any script into a folder and its output is displayed in the menu bar, while its timing is ingenious in that you just add "3s" or "2h" or "1d" to its name like: myScript.3s.sh which is accordingly updated/executed. . . . . . I use it to let a script call an AppleScript that outputs [ 3 ] if I change to desktop 3. . . . . . Sooooo easy ! Dec 17, 2018 at 8:12
  • BitBar has somehow blown up in popularity apparently...... More than 12K stars on GitHub already. Indeed very straightforward to use.
    – xji
    Apr 5, 2020 at 0:39
  • Yes, it was popular at the time, but the last release was on 30 Aug 2016 (almost 4 years ago) and the most recent notable activity is mostly from merging PRs
    – Chris
    Apr 6, 2020 at 11:41
2

I was searching for such tool many times until I have implemented that for my self: http://shellwrangler.com. No ads, it’s free and you can build anything you like.

2

I finally found what I've been looking for. In fact, it’s much better than what I was hoping for:

TextBar

  • Configure TextBar to run multiple scripts/commands/etc and display the results in your menubar.
  • Click the TextBar item to add the text to your clipboard.
  • Enable/disable each item individually.
  • Configure how often you want each item to be updated.
  • add an icon for each menubar item (or none)

I’ve been using this for the past week or so and it’s great.

$3. Demo available at http://www.richsomerfield.com/apps/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .