diff options
| -rwxr-xr-x | configure | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -2,19 +2,37 @@ git checkout config.h -for BAT in /sys/class/power_supply/BAT* +# CPU temp reporting is cancer +# find a correct file assuming CPU is the hottest element +Tmax="0" +for f in /sys/class/hwmon/hwmon*/temp*_input do + T="$(cat "$f")" + if [ "$T" -gt "$Tmax" ]; then + Tmax="$T" + CPUtemp="$f" + fi +done +sed -i "/cpu_perc/a{ temp, \"%s° \", \"$CPUtemp\"}," config.h + +# detect battery +for BAT_path in /sys/class/power_supply/BAT* +do + BAT="$(basename "$BAT_path")" sed -i "/BATSTATE/a { battery_state, \"%s]\", \"$BAT\"}," config.h sed -i "/BATSTATE/a { battery_perc, \"[%s\", \"$BAT\"}," config.h done -ETH="$(ip link | grep enp | cut -d':' -f2 | xargs)" +# detect ethernet interfaces +# WARNING: currently will fail with multiple interfaces due to as slstatus stores the # of bytes sent in a static variable +ETH="$(ip link | grep ': en' | cut -d':' -f2 | xargs)" if [ -n "$ETH" ]; then sed -i "/NETSPEED/a{ netspeed_tx, \"%7s]\", \"$ETH\"}," config.h - sed -i "/NETSPEED/a{ netspeed_rx, \"[E%7s \", \"$ETH\"}," config.h + sed -i "/NETSPEED/a{ netspeed_rx, \"[%7s \", \"$ETH\"}," config.h fi -WLAN="$(ip link | grep wlp | cut -d':' -f2 | xargs)" +# detect wireless interfaces +WLAN="$(ip link | grep ': wlp' | cut -d':' -f2 | xargs)" if [ -n "$WLAN" ]; then sed -i "/NETSPEED/a{ netspeed_tx, \"%7s]\", \"$WLAN\"}," config.h sed -i "/NETSPEED/a{ netspeed_rx, \"%7s \", \"$WLAN\"}," config.h |
