Script for Local IP

I'm testing out BetterTouchTool for the first time and am really liking it so far. I have never done any Apple Scripting before though. I'd like to display my local IP address in the touch bar or at the very least have a button to display IP. Has anyone done this? Thanks in advance!

Nothing easier than this. Add a function "+ Widget/Gesture" And select "Run Apple Script and return value".
Run the script

set ipaddress to IPv4 address of (get system info)
return ipaddress

And that's it.
If you want to copy the IP to your clipboard, set the Predefined action "Run Apple Script (async in Background) and paste

set ipaddress to IPv4 address of (get system info)
set the clipboard to ipaddress

Basta :slightly_smiling_face:
For energy reasons I'd put it into a TouchBar group and run it only when visible (so when you open the group).

I made something quick with these settings.
IP Address Script.json (11.4 KB)

Hope it's what you were looking for!

1 Like

Thank you so much! That is a big help. I'm wanting to create a "network info" button that will dispaly IP, MAC and public IP information from the touchbar. I'm often connected both wired and wirelessly so being table to query those two NIC's individually would be helpful. This is a great start.

Created a group during my break that displays:

  • your MAC address
    • if you tap it it copies the MAC address to your clipboard
  • your IP and Public IP in two lines
    • if you tap it it copies the IP address to your clipboard
    • if you long tap it it copies the Public IP address to your clipboard

Gonna clean it up (delete my group-default buttons and triggers from the Caliguvara C2 preset) and post two JSONs later with the group and the trigger (needed for the long tap).

Here you go.
Network Group.json (102.1 KB)
Trigger (Needed to Copy Public IP).json (1.2 KB)
I'm afraid the group might not appear at the top of your list, just search for it I'm sure you'll find it :slightly_smiling_face:

Thank you so much! I've been playing with this & working on customization. The issue I see with querying the system info is that it only shows you your primary IP and not secondary NIC's Often times I'm plugged in wired & wireless. This is a great start though.