#!/usr/bin/env bash
# nm-wifi-list -- list Wi-Fi networks through NetworkManager
#
# A simple wrapper that just reorders the columns to fit on my screens.

if [[ -t 1 ]]; then
	colors=yes
else
	colors=auto
fi

rescan=no

while getopts "cr" OPT; do
	case $OPT in
	c) colors=yes;;
	r) rescan=yes;;
	*) exit 2;;
	esac
done; shift $((OPTIND-1))

fields="in-use,bars,ssid,bssid,chan,rate,security,mode"

nmcli -f $fields -c $colors dev wifi list --rescan $rescan | cat
