Wifi toggle with icon color change on touch bar

I would like to implement a wifi toggle on my touch bar that has shows a blue icon when enabled, and a white one when disabled.

I managed to do this for Bluetooth, but I'm struggling with finding the right AppleScript to check the wifi status and enable/disable it.

Can anyone help? :slight_smile:

Could you share how you enabled the Bluetooth icon color change when toggled on and off???
I cannot figure it out at all.

Hi @Peter_Michael_Lopez, I don't have a Mac with a Touch Bar anymore so I can't recreate your desired setup completely, but here's how I would go about it:

  1. Create a "Shell Script / Task Widget".
  2. Add this shell script in the configuration settings:
# 1) Grab raw state ("attrib_on" or "attrib_off")
state=$(
  system_profiler -json SPBluetoothDataType \
    | jq -r '.SPBluetoothDataType[0].controller_properties.controller_state'
)

# 2) Choose colors and text based on state
if [[ "$state" == "attrib_on" ]]; then
  TEXT="Bluetooth On"
  BACKGROUND="0,200,100,255"    # green-ish RGBA
  FONT_COLOR="255,255,255,255"  # white
else
  TEXT="Bluetooth Off"
  BACKGROUND="150,150,150,255"  # gray-ish RGBA
  FONT_COLOR="255,255,255,255"  # white
fi

# 3) Echo a single-line JSON string (keys/values in single quotes, entire thing in double quotes).
#    BTT will parse this and use your colors/font/size/text.
echo "{\
'text':'$TEXT',\
'icon_path':'',\
'background_color':'$BACKGROUND',\
'font_color':'$FONT_COLOR',\
'font_size':12\
}"

It should look like this:

I hope this helps.