#!/bin/bash

case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
  down) printf "^c#ffffff^^b#770000^no wifi^d^" ;;
  up)
    [ -n "$(ip address show dev wlan0 | grep 'inet ')" ] \
      && printf "$(iw dev wlan0 info | grep 'ssid ' | cut -d' ' -f2-)" \
      || printf "^c#ffffff^^b#770000^no ip^d^" ;;
esac
