64 lines
1.4 KiB
Bash
64 lines
1.4 KiB
Bash
|
#!/bin/sh
|
||
|
|
||
|
# t2stats:
|
||
|
# this is a simple network/battery status indicator to be used with tint2
|
||
|
# (c) 2020 Derek Stevens <drkste@zoho.com>
|
||
|
# MIT License -- do whatever you want
|
||
|
|
||
|
while true; do
|
||
|
# network
|
||
|
actives=$(nmcli connection show --active)
|
||
|
possiblywifi=$(echo "${actives}" | grep wifi)
|
||
|
possiblyeth=$(echo "${actives}" | grep Wired)
|
||
|
ORS=" "
|
||
|
|
||
|
if [ ! -z "${possiblyeth}" ]; then
|
||
|
output=wired
|
||
|
elif [ ! -z "${possiblywifi}" ]; then
|
||
|
output="wifi/$(echo ${possiblywifi} | awk 'BEGIN { ORS=" " }; {for (i=1; i<=(NF-3);i++) print $i}')"
|
||
|
else
|
||
|
output=offline
|
||
|
fi
|
||
|
|
||
|
echo -n "${output} "
|
||
|
|
||
|
# battery
|
||
|
|
||
|
powerlevel=$(cat /sys/class/power_supply/BAT*/capacity)
|
||
|
case $powerlevel in
|
||
|
1|2|3|4|5|6|7|8|9)
|
||
|
meter="[| ]"
|
||
|
;;
|
||
|
10|11|12|13|14|15|16|17|18|19)
|
||
|
meter="[|| ]"
|
||
|
;;
|
||
|
20|21|22|23|24|25|26|27|28|29)
|
||
|
meter="[||| ]"
|
||
|
;;
|
||
|
30|31|32|33|34|35|36|37|38|39)
|
||
|
meter="[|||| ]"
|
||
|
;;
|
||
|
40|41|42|43|44|45|46|47|48|49)
|
||
|
meter="[||||| ]"
|
||
|
;;
|
||
|
50|51|52|53|54|55|56|57|58|59)
|
||
|
meter="[|||||| ]"
|
||
|
;;
|
||
|
60|61|62|63|64|65|66|67|68|69)
|
||
|
meter="[||||||| ]"
|
||
|
;;
|
||
|
70|71|72|73|74|75|76|77|78|79)
|
||
|
meter="[|||||||| ]"
|
||
|
;;
|
||
|
80|81|82|83|84|85|86|87|88|89)
|
||
|
meter="[||||||||| ]"
|
||
|
;;
|
||
|
*)
|
||
|
meter="[||||||||||]"
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
echo "${meter}"
|
||
|
|
||
|
sleep 10
|
||
|
done
|