Networkwidget: Add support for bt power levels.
This commit is contained in:
parent
480725e3fc
commit
3e06633cec
|
@ -69,6 +69,7 @@ in {
|
|||
#custom-display.modified,
|
||||
#custom-network.issue,
|
||||
#custom-network.vpn,
|
||||
#custom-network.btlow,
|
||||
#memory.critical,
|
||||
#pulseaudio.muted,
|
||||
#pulseaudio.source-muted,
|
||||
|
|
|
@ -83,29 +83,29 @@
|
|||
class="modified"
|
||||
fi
|
||||
|
||||
printf "{\"text\": \"\", \"tooltip\": \"DND: ''${_dndstate} / Monitor: ''${_monitorstate} / Gaming: ''${_gamingstate} / Recording: ''${_recordingstate}\", \"class\": \"''${class}\"}\n"
|
||||
printf "%s" "{\"text\": \"\", \"tooltip\": \"DND: ''${_dndstate} / Monitor: ''${_monitorstate} / Gaming: ''${_gamingstate} / Recording: ''${_recordingstate}\", \"class\": \"''${class}\"}\n"
|
||||
}
|
||||
|
||||
function monitorstate() {
|
||||
local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .power'))
|
||||
|
||||
for state in "''${outputs[@]}"; do
|
||||
''${state} || {
|
||||
printf Y
|
||||
''${state} || {
|
||||
printf "%s" Y
|
||||
return 1
|
||||
}
|
||||
done
|
||||
|
||||
printf n
|
||||
printf "%s" n
|
||||
return 0
|
||||
}
|
||||
|
||||
function recordingstate() {
|
||||
[[ "$(ps cax | rg wf-recorder)" = "" ]] && printf n || printf Y
|
||||
[[ "$(ps cax | rg wf-recorder)" = "" ]] && printf "%s" n || printf "%s" Y
|
||||
}
|
||||
|
||||
function dndstate() {
|
||||
[[ "$(makoctl mode)" = "dnd" ]] && printf Y || printf n
|
||||
[[ "$(makoctl mode)" = "dnd" ]] && printf "%s" Y || printf "%s" n
|
||||
}
|
||||
|
||||
function gamingstate() {
|
||||
|
@ -113,12 +113,12 @@
|
|||
|
||||
for state in "''${outputs[@]}"; do
|
||||
[[ "''${state}" = "disabled" ]] || {
|
||||
printf Y
|
||||
printf "%s" Y
|
||||
return 1
|
||||
}
|
||||
done
|
||||
|
||||
printf n
|
||||
printf "%s" n
|
||||
return 0
|
||||
}
|
||||
'';
|
||||
|
|
|
@ -7,12 +7,32 @@
|
|||
local _ethernets=($(nmcli connection show --active | rg ethernet | sed "s/ .*//"))
|
||||
local _vpns=($(nmcli connection show --active | rg vpn | sed "s/ .*//"))
|
||||
local _wifis=($(nmcli connection show --active | rg wifi | sed "s/ .*//"))
|
||||
local _bts=($(bluetoothctl devices Connected | cut -d\ -f3))
|
||||
local _bts_raw=($(bluetoothctl devices Connected))
|
||||
local _bts=()
|
||||
local _bt_lowest=100
|
||||
local icon=""
|
||||
local class=""
|
||||
|
||||
for bt in ''${_bts_raw[@]}; do
|
||||
local name=$(printf "%s" ''${bt} | cut -d\ -f3)
|
||||
local mac=$(printf "%s" ''${bt} | cut -d\ -f2 | sed -e "s/:/_/g")
|
||||
local bat=$(dbus-send --print-reply=literal --system --dest=org.bluez /org/bluez/hci0/dev_''${mac} org.freedesktop.DBus.Properties.Get string:"org.bluez.Battery1" string:"Percentage" 2> /dev/null | cut -d\ -f12)
|
||||
local btinfo="''${name}"
|
||||
|
||||
if [[ "''${bat}" != "" ]]; then
|
||||
btinfo+=" ''${bat}%"
|
||||
[[ ''${bat} -lt ''${_bt_lowest} ]] && _bt_lowest=bat
|
||||
fi
|
||||
|
||||
_bts+=("''${btinfo}")
|
||||
done
|
||||
|
||||
if [[ "''${_bts}" != "" ]]; then
|
||||
icon=""
|
||||
|
||||
if [[ "''${_bt_lowest}" != "" ]] && [[ ''${_bt_lowest} -lt 20 ]]; then
|
||||
class="btlow"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "''${_vpns}" != "" ]]; then
|
||||
|
@ -26,23 +46,23 @@
|
|||
fi
|
||||
|
||||
for net in ''${_vpns[@]}; do
|
||||
networks+=" ''${net}\\\n"
|
||||
networks+=" ''${net}\\n"
|
||||
done
|
||||
|
||||
for net in ''${_ethernets[@]}; do
|
||||
networks+=" ''${net}\\\n"
|
||||
networks+=" ''${net}\\n"
|
||||
done
|
||||
|
||||
for net in ''${_wifis[@]}; do
|
||||
networks+=" ''${net}\\\n"
|
||||
networks+=" ''${net}\\n"
|
||||
done
|
||||
|
||||
for bt in ''${_bts[@]}; do
|
||||
networks+=" ''${bt}\\\n"
|
||||
networks+=" ''${bt}\\n"
|
||||
done
|
||||
|
||||
networks=''${networks%\\\n}
|
||||
printf "{\"text\": \"''${icon}\", \"tooltip\": \"''${networks}\", \"class\": \"''${class}\"}\n"
|
||||
networks=''${networks%\\n}
|
||||
printf "%s" "{\"text\": \"''${icon}\", \"tooltip\": \"''${networks}\", \"class\": \"''${class}\"}\n"
|
||||
}
|
||||
|
||||
# Toggle network.
|
||||
|
|
Loading…
Reference in a new issue