AnyBar is a macOS status indicator that displays a "colored dot" in the menu bar that can be changed programatically. What it means and when it changes is entirely up to the user.
You can easily install it with Homebrew-cask:
$ brew cask install anybar
The README lists a number of alternative clients in different programming languages. I thought it would be fun to show how to use it from Factor. Since AnyBar responds to AppleScript (and I added support for AppleScript a few years ago), we could do this:
USE: cocoa.apple-script "tell application \"AnyBar\" to set image name to \"blue\"" run-apple-script
The AnyBar application also listens to a UDP port (default: 1738) and can be instructed to change from a Terminal using a simple echo | nc command:
$ echo -n "blue" | nc -4u -w0 localhost 1738
Using our networking words similarly is pretty simple:
"blue" >byte-array "127.0.0.1" 1738 <inet4> send-once
But if we wanted to get more fancy, we could use symbols to configure which AnyBar instance to send to, with default values to make it easy to use, and resolve-host to lookup hostnames:
SYMBOL: anybar-host "localhost" anybar-host set-global SYMBOL: anybar-port 1738 anybar-port set-global : anybar ( str -- ) ascii encode anybar-host get resolve-host first anybar-port get with-port send-once ;
AnyBar is a neat little program!
No comments:
Post a Comment