Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
    
See GeekTool! projects.tynsoe.org/en/geektool –  user588 Jun 9 '12 at 2:48
    
GeekTool = Desktop, not menu bar. –  TJ Luoma Jun 9 '12 at 3:34
    
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 '12 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 '12 at 11:45
    
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 '12 at 12:31
add comment

1 Answer

#!/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.

share|improve this answer
    
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 '12 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.) –  Lauri Ranta Jun 10 '12 at 4:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.