nixos-config/profiles/workspace/i3blocks/scripts/connections.nix

65 lines
1.7 KiB
Nix
Raw Normal View History

2020-02-17 17:00:59 +04:00
{ bash, networkmanager, iconfont, config, modemmanager, ... }: ''
#!${bash}/bin/bash
CONNECTIONS=$(${networkmanager}/bin/nmcli con show --active | tail +2 | tr -s ' ' | rev | cut -d' ' -f3 | rev)
text=""
for connection in $CONNECTIONS
do
grep wifi <<< $connection > /dev/null && {
2020-07-27 01:16:19 +04:00
# SIGNAL=$(${networkmanager}/bin/nmcli d w | grep '^\*' | tr -s ' ' | cut -d' ' -f7)
# if [[ $SIGNAL -lt 20 ]]
# then
# text+=冷
# elif [[ $SIGNAL -lt 40 ]]
# then
# text+=爛
# elif [[ $SIGNAL -lt 60 ]]
# then
# text+=嵐
# elif [[ $SIGNAL -lt 80 ]]
# then
# text+=襤
# else
# text+=蠟
# fi
text=
2020-02-17 17:00:59 +04:00
}
grep gsm <<< $connection >/dev/null && {
MODEM=$(${modemmanager}/bin/mmcli -K -L | tail -1 | cut -d: -f2 | tr -d ' ')
STATUS=$(${modemmanager}/bin/mmcli -K -m $MODEM)
TECH=$(grep "modem.generic.access-technologies.value\[1\]" <<< $STATUS | cut -d: -f2 | tr -d ' ')
2020-07-27 01:16:19 +04:00
# SIGNAL=$(grep "modem.generic.signal-quality.value" <<< $STATUS | cut -d: -f2 | tr -d ' ')
# if [[ $SIGNAL -lt 20 ]]
# then
# text+=""
# elif [[ $SIGNAL -lt 40 ]]
# then
# text+=""
# elif [[ $SIGNAL -lt 60 ]]
# then
# text+=""
# elif [[ $SIGNAL -lt 80 ]]
# then
# text+=""
# else
# text+=""
# fi
text+=
2020-02-17 17:00:59 +04:00
if [[ $TECH == lte ]]
then
2020-07-27 01:16:19 +04:00
text+=""
2020-02-17 17:00:59 +04:00
else
2020-07-27 01:16:19 +04:00
text+=""
2020-02-17 17:00:59 +04:00
fi
}
2020-07-27 01:16:19 +04:00
grep ethernet <<< $connection > /dev/null && text+=""
2020-02-17 17:00:59 +04:00
done
code=0
[[ $text == "" ]] && {
2020-07-27 01:16:19 +04:00
text=
2020-02-17 17:00:59 +04:00
code=33
}
echo "<span font='${iconfont}'>$text</span>"
exit $code
''