Add temperature sensor
authorSiraaj Khandkar <siraaj@khandkar.net>
Fri, 22 Mar 2019 19:47:07 +0000 (15:47 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Fri, 22 Mar 2019 19:47:07 +0000 (15:47 -0400)
x4/bin/khatus_x4_sensor_temp [new file with mode: 0755]
x4/sanity_check

diff --git a/x4/bin/khatus_x4_sensor_temp b/x4/bin/khatus_x4_sensor_temp
new file mode 100755 (executable)
index 0000000..2ade37c
--- /dev/null
@@ -0,0 +1,32 @@
+#! /bin/sh
+
+set -e
+
+bin_dir="$(dirname $(realpath $0))"
+
+. "$bin_dir/khatus_x4_lib_common_sensor.sh"
+
+while :
+do
+    case "$1"
+    in '')
+        break
+    ;; -z|--zone)
+        case "$2"
+        in '')
+            printf "Option $1 requires and argument\n" >&2
+            exit 1
+        ;; *)
+            thermal_zone="thermal_zone${2}"
+            shift 2
+        esac
+    ;; *)
+        shift 1
+    esac
+done
+
+sensor() {
+    echo "$thermal_zone $(( $(cat /sys/class/thermal/${thermal_zone}/temp) / 1000 ))"
+}
+
+run_as_poller
index 62a23ea..125369a 100755 (executable)
@@ -22,6 +22,7 @@ sensors_fork_all() {
     ./bin/khatus_x4_sensor_energy   &
     ./bin/khatus_x4_sensor_memory   &
     ./bin/khatus_x4_sensor_loadavg  &
+    ./bin/khatus_x4_sensor_temp -i 1 -- -z 0 &
 }
 
 sensor_read_one() {
@@ -44,7 +45,8 @@ sensors_read_all() {
         mpd="$(sensor_read_one ${dir}/khatus_x4_sensor_mpd/out/status)"
         mem="$(sensor_read_one ${dir}/khatus_x4_sensor_memory/out/percent_used)"
         load="$(sensor_read_one ${dir}/khatus_x4_sensor_loadavg/out/load_avg_1min)"
-        echo "E[${battery_state} ${battery_percentage}] M:${mem}% L:${load} [${mpd}] [$bluetooth_controllers $bluetooth_devices] ${datetime}"
+        temp="$(sensor_read_one ${dir}/khatus_x4_sensor_temp/out/thermal_zone0)"
+        echo "E[${battery_state} ${battery_percentage}] M:${mem}% L:${load} T:${temp}°C [${mpd}] [$bluetooth_controllers $bluetooth_devices] ${datetime}"
         sleep 1
     done
 }
This page took 0.020013 seconds and 4 git commands to generate.