Networkwidget: Add support for bt power levels.
This commit is contained in:
parent
15a2b9b1fc
commit
69eb5390c4
|
@ -69,6 +69,7 @@ in {
|
||||||
#custom-display.modified,
|
#custom-display.modified,
|
||||||
#custom-network.issue,
|
#custom-network.issue,
|
||||||
#custom-network.vpn,
|
#custom-network.vpn,
|
||||||
|
#custom-network.btlow,
|
||||||
#memory.critical,
|
#memory.critical,
|
||||||
#pulseaudio.muted,
|
#pulseaudio.muted,
|
||||||
#pulseaudio.source-muted,
|
#pulseaudio.source-muted,
|
||||||
|
|
|
@ -83,29 +83,29 @@
|
||||||
class="modified"
|
class="modified"
|
||||||
fi
|
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() {
|
function monitorstate() {
|
||||||
local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .power'))
|
local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .power'))
|
||||||
|
|
||||||
for state in "''${outputs[@]}"; do
|
for state in "''${outputs[@]}"; do
|
||||||
''${state} || {
|
''${state} || {
|
||||||
printf Y
|
printf "%s" Y
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
printf n
|
printf "%s" n
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function recordingstate() {
|
function recordingstate() {
|
||||||
[[ "$(ps cax | rg wf-recorder)" = "" ]] && printf n || printf Y
|
[[ "$(ps cax | rg wf-recorder)" = "" ]] && printf "%s" n || printf "%s" Y
|
||||||
}
|
}
|
||||||
|
|
||||||
function dndstate() {
|
function dndstate() {
|
||||||
[[ "$(makoctl mode)" = "dnd" ]] && printf Y || printf n
|
[[ "$(makoctl mode)" = "dnd" ]] && printf "%s" Y || printf "%s" n
|
||||||
}
|
}
|
||||||
|
|
||||||
function gamingstate() {
|
function gamingstate() {
|
||||||
|
@ -113,12 +113,12 @@
|
||||||
|
|
||||||
for state in "''${outputs[@]}"; do
|
for state in "''${outputs[@]}"; do
|
||||||
[[ "''${state}" = "disabled" ]] || {
|
[[ "''${state}" = "disabled" ]] || {
|
||||||
printf Y
|
printf "%s" Y
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
|
||||||
printf n
|
printf "%s" n
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -7,12 +7,32 @@
|
||||||
local _ethernets=($(nmcli connection show --active | rg ethernet | sed "s/ .*//"))
|
local _ethernets=($(nmcli connection show --active | rg ethernet | sed "s/ .*//"))
|
||||||
local _vpns=($(nmcli connection show --active | rg vpn | sed "s/ .*//"))
|
local _vpns=($(nmcli connection show --active | rg vpn | sed "s/ .*//"))
|
||||||
local _wifis=($(nmcli connection show --active | rg wifi | 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 icon=""
|
||||||
local class=""
|
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
|
if [[ "''${_bts}" != "" ]]; then
|
||||||
icon=""
|
icon=""
|
||||||
|
|
||||||
|
if [[ "''${_bt_lowest}" != "" ]] && [[ ''${_bt_lowest} -lt 20 ]]; then
|
||||||
|
class="btlow"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "''${_vpns}" != "" ]]; then
|
if [[ "''${_vpns}" != "" ]]; then
|
||||||
|
@ -26,23 +46,23 @@
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for net in ''${_vpns[@]}; do
|
for net in ''${_vpns[@]}; do
|
||||||
networks+=" ''${net}\\\n"
|
networks+=" ''${net}\\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
for net in ''${_ethernets[@]}; do
|
for net in ''${_ethernets[@]}; do
|
||||||
networks+=" ''${net}\\\n"
|
networks+=" ''${net}\\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
for net in ''${_wifis[@]}; do
|
for net in ''${_wifis[@]}; do
|
||||||
networks+=" ''${net}\\\n"
|
networks+=" ''${net}\\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
for bt in ''${_bts[@]}; do
|
for bt in ''${_bts[@]}; do
|
||||||
networks+=" ''${bt}\\\n"
|
networks+=" ''${bt}\\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
networks=''${networks%\\\n}
|
networks=''${networks%\\n}
|
||||||
printf "{\"text\": \"''${icon}\", \"tooltip\": \"''${networks}\", \"class\": \"''${class}\"}\n"
|
printf "%s" "{\"text\": \"''${icon}\", \"tooltip\": \"''${networks}\", \"class\": \"''${class}\"}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Toggle network.
|
# Toggle network.
|
||||||
|
|
Loading…
Reference in a new issue