One (More?) Thing
Part of the Mac series
Just about one year ago, Joe Rosensteel wrote on SixColors about putting local weather data in his menu bar. Aside from the entire system that gets the weather and gets it to his computer, the way he displays it in the menu bar is with a little utility app called One Thing. I thought it was a cool app, and I downloaded it, but never really made use of it. Until today.
Today I was digging through web server logs to solve a non-pressing but quite interesting problem, and I realized I was tired of using What’s My IP type web services to see who I am so I would know which log entries on my server are me. I put the IP in Tot so I could easily refer to it, and then I thought, “that’s great, but what about when it eventually changes?” Even though it almost never happens, it does happen very occasionally. Also, when I’m working with my terminal app in fullscreen mode, I don’t want to have to dig around for a note.
Enter One Thing.
I figured the easiest way to get a value into One Thing for this purpose would be from the command line, so I installed the One Thing command line tool. Then I googled for a nice command to get my external ip address from the command line and found
I decided to make Peter happy by making ChatGPT do my scripting for me and asked MacGPT to write a bash script that runs the dig command, removes the quotes the dig command places around the IP address, and then passes the output to the one-thing command line tool. That script looks like this:
The comments in the script are MacGPT’s, by the way.
Although I’ve done tons of cron jobs on linux servers, I don’t think I’ve ever actually scheduled any tasks on a Mac in recent history. I knew I was going to want to use launchd but I was fuzzy on the details. I asked MacGPT what to do, and it told me to make a plist file that references my bash script, shove it in /Library/LaunchDaemons, and set some file permissions and file ownership settings, and register it with launchd using the launchctl command.
I replied, “that’s cool, but maybe you should write the plist file for me”, and it did.
I moved this file to /Library/LaunchDaemons, set owner and permissions with sudo chown root:wheel com.scottwillsey.my-ip-address.plist
and sudo chmod 644 com.scottwillsey.my-ip-address.plist
.
Now /Library/LaunchDaemons looks like this:
As usual, the script itself needs execute permissions.
And now I have my IP address in my menu bar!
By the way, the IP address shown isn’t really mine. It’s Microsoft’s. Don’t try to DDOS them, but if you do I can only assume they have better DDOS protection than I do.