#!/bin/sh

if networksetup -getairportpower en0 | grep -q "On"; then
  SSID=$(ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}')
  if [ -z "$SSID" ]; then
    sketchybar --set wifi icon="󱛅" \
                          label="Disconnected" \
                          label.color="0xffed8796" \
                          icon.color="0xffed8796"
  else
    sketchybar --set wifi icon="󰖩" \
                          label="$SSID" \
                          label.color="0xffc6a0f6" \
                          icon.color="0xffc6a0f6"
  fi
else
  sketchybar --set wifi icon="󰖪" \
                        label="Off" \
                        label.color="0xffed8796" \
                        icon.color="0xffed8796"
fi
