18 lines
795 B
Bash
Executable file
18 lines
795 B
Bash
Executable file
#!/bin/bash
|
|
|
|
|
|
function ifstatus(){
|
|
jq -cs '{"interfaces": [(.[0].devs[] | select((.type=="wifi") or (.type=="ethernet")))]} * {"vpns": [(.[1].cons[] | select((.type=="vpn") or (.type=="wireguard")))]}' <<<$( \
|
|
# nmcli --terse -f DEVICE,TYPE,STATE,CONNECTION d s | column -t -n 'devs' --table-columns device,type,state,connection -s ':' -J; \
|
|
nmcli --terse -f DEVICE,TYPE,STATE,CONNECTION d s | sed 's/\\:/###/g;s/:/\;/g;s/###/:/g' | column -t -n 'devs' --table-columns device,type,state,connection -s ';' -J; \
|
|
nmcli --terse -f NAME,TYPE,ACTIVE,DEVICE c s | column -t -n 'cons' --table-columns name,type,active,device -s ':' -J)
|
|
# [ .devices[] | select((.type=="wifi") or (.type=="ethernet")) ]
|
|
}
|
|
|
|
ifstatus
|
|
|
|
ip monitor address | {
|
|
while read -r event; do
|
|
ifstatus
|
|
done;
|
|
}
|