2022-01-14 04:57:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# t2stats:
|
|
|
|
# this is a simple network/battery status indicator to be used with tint2
|
|
|
|
|
|
|
|
if [ "$1" = "-l" ]; then
|
2022-01-15 05:33:32 +00:00
|
|
|
load=$(cat /proc/loadavg)
|
|
|
|
set -- ${load}
|
2022-03-26 15:10:26 +00:00
|
|
|
load=$1
|
2022-01-15 05:33:32 +00:00
|
|
|
|
2022-01-14 04:57:24 +00:00
|
|
|
memdata=$(free -h --si | grep Mem)
|
|
|
|
swapdata=$(free -h --si | grep Swap)
|
2022-01-15 05:33:32 +00:00
|
|
|
|
|
|
|
set -- ${memdata}
|
|
|
|
memused=$3
|
|
|
|
|
|
|
|
set -- ${swapdata}
|
|
|
|
swapused=$3
|
2022-01-14 04:57:24 +00:00
|
|
|
|
|
|
|
echo " ${load} | ${memused} | ${swapused}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "-r" ]; then
|
|
|
|
|
|
|
|
# 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} |\
|
2022-01-15 05:33:32 +00:00
|
|
|
awk 'BEGIN { ORS=" " }; {for (i=1; i<=(NF-3);i++) print $i}')"
|
2022-01-14 04:57:24 +00:00
|
|
|
else
|
|
|
|
output=offline
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n "${output}"
|
|
|
|
|
|
|
|
# battery
|
|
|
|
if ! grep Full /sys/class/power_supply/BAT*/status > /dev/null \
|
2022-01-15 05:33:32 +00:00
|
|
|
&& [ -d /sys/class/power_supply/BAT* ]; then
|
|
|
|
powerlevel=$(cat /sys/class/power_supply/BAT*/capacity)
|
2023-03-28 05:19:23 +00:00
|
|
|
state=$(cat /sys/class/power_supply/BAT*/status)
|
|
|
|
left=""
|
|
|
|
right=""
|
|
|
|
case $state in
|
|
|
|
Discharging)
|
|
|
|
right="-";;
|
|
|
|
Charging)
|
|
|
|
right="+";;
|
|
|
|
Charged)
|
|
|
|
right="=";;
|
|
|
|
esac
|
2022-01-15 05:33:32 +00:00
|
|
|
case $powerlevel in
|
|
|
|
0)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
1|2|3|4|5|6|7|8|9)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
10|11|12|13|14|15|16|17|18|19)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
20|21|22|23|24|25|26|27|28|29)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
30|31|32|33|34|35|36|37|38|39)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
40|41|42|43|44|45|46|47|48|49)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
50|51|52|53|54|55|56|57|58|59)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
60|61|62|63|64|65|66|67|68|69)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
70|71|72|73|74|75|76|77|78|79)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left} ${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
80|81|82|83|84|85|86|87|88|89)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left}${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
*)
|
2023-03-28 05:19:23 +00:00
|
|
|
meter="${left}${right}"
|
2022-01-15 05:33:32 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-01-14 04:57:24 +00:00
|
|
|
echo " ${meter}"
|
|
|
|
fi
|
|
|
|
fi
|