New backup 2025-03-12 19:45:01

This commit is contained in:
Penelope Gwen 2025-03-12 19:45:01 -07:00
parent ba1a133294
commit cde6130c8d

View file

@ -1,33 +1,48 @@
#!/bin/bash #!/bin/bash
function ifstatus(){ function btstatus(){
is_wireless=false device_mac_list=$(bluetoothctl devices Paired | awk '{print $2}')
is_ethernet=false device_json_array=()
is_proton=false
is_homevpn=false
if nmcli -g TYPE connection show --active | grep -q "wireless";then for m in ${device_mac_list};do
is_wireless='true' device_name="$(bluetoothctl info ${m} | grep 'Name: ' | sed 's/.*Name: //')"
fi device_connected="$(bluetoothctl info ${m} | grep 'Connected: ' | sed 's/.*Connected: //')"
if nmcli -g TYPE connection show --active | grep -q "ethernet";then device_icon="$(bluetoothctl info ${m} | grep 'Icon: ' | sed 's/.*Icon: //')"
is_ethernet='true' case "${device_icon}" in
fi "input-mouse")
if nmcli -g TYPE,NAME connection show --active | grep -e "vpn" -e "wireguard" | grep -qi "proton";then device_icon="🖯"
is_proton='true' ;;
fi "phone")
if nmcli -g TYPE,NAME connection show --active | grep -e "vpn" -e "wireguard" | grep -qi "home";then device_icon=""
is_homevpn='true' ;;
fi "input-keyboard")
device_icon=""
echo $(jq -n --arg wifi "${is_wireless}" --arg wired "${is_ethernet}" --arg proton "${is_proton}" --arg homevpn "${is_homevpn}" '{wifi: $wifi, wired: $wired, proton: $proton, homevpn: $homevpn}') ;;
"input-gaming")
device_icon=""
;;
"audio-headphones")
device_icon=""
;;
"audio-headset")
device_icon=""
;;
"computer")
device_icon=""
;;
esac
device_json=$( jq -n --arg name "${device_name}" --arg connected "${device_connected}" --arg icon "${device_icon}" --arg address "${m}" '{name: $name, connected: $connected, icon: $icon, address: $address}')
device_json_array+=("${device_json}")
done
devices_json=$(printf '%s\n' "${device_json_array[@]}" | jq -s .)
echo ${devices_json}
} }
ifstatus btstatus
ip monitor address | { bluetoothctl | awk '/Device.*Connected/' | {
while read -r event; do while read -r event; do
# echo hi ${event}; btstatus
ifstatus
done; done;
} }