summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan-boikov <ik.boikov.public@protonmail.com>2024-02-29 21:04:18 +0100
committerivan-boikov <ik.boikov.public@protonmail.com>2024-02-29 21:04:18 +0100
commit355055d36f1248e4b3dc70c901dfb00e66a4d236 (patch)
treebecdffae48b63567868719b0bddf3bc99c664c1d
parent6229bf45137a8f61a8cb36e8dd8eff3e365bb4d7 (diff)
CPU temp detection, BAT basename fix, ethernet icon
-rwxr-xr-xconfigure26
1 files changed, 22 insertions, 4 deletions
diff --git a/configure b/configure
index 4664f2b..938ea05 100755
--- a/configure
+++ b/configure
@@ -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