#!/usr/bin/env zsh

let bluetooth=1
if [[ "${1}" == '--no-bluetooth' ]] || [[ "${1}" == '-n' ]]; then
   bluetooth=0
fi

if [[ "$(uname)" = 'Linux' ]]; then
    local active_networks="$(nmcli --fields type c s --active)"
    local output=''
    [[ "${active_networks}" = *'wifi'* ]] && output="${output}󰖩 "
    [[ "${active_networks}" = *'ethernet'* ]] && output="${output}󰈁"
    [[ "${active_networks}" = *'wireguard'* ]] && output="${output}󰖂 "
    (( ${#output} == 0 )) && output='󰈂'
    if (( bluetooth )); then
        bluetoothctl show | grep 'Powered: yes' >/dev/null && output="${output}  "
    fi
    printf '%s\n' "${output}"
else
    echo "${0}: error: unknown os: \"$(uname)\"" >&2
    exit 1
fi
