getwifi 320 B

12345678910111213
  1. #!/bin/sh
  2. # get SSID and local IP if connected otherwise 'down'
  3. # requires root privileges
  4. ssid_ip="$(sudo wpa_cli status \
  5. | sed -n '4s/^ssid=//p;11s/^ip_address=//p' \
  6. | tr '\n' ' ' \
  7. )"
  8. # remove single trailing whitespace
  9. ssid_ip="${ssid_ip%\ }"
  10. echo "${ssid_ip:=down}"