#!/bin/env bash

CONN_INFO=$(nmcli -g in-use,ssid,signal dev wifi list | \
    grep "^*" | \
    sed -e 's/\*:\([^:]*\):\([0-9]*\)/ ,"ssid": "\1", "signal": \2/')
CONNECTED=$([[ -z $CONN_INFO ]] && echo "false" || echo "true")

echo "{\"connected\": \"$CONNECTED\"$CONN_INFO}"
