aboutsummaryrefslogtreecommitdiff
path: root/.config/luastatus-scripts-dwm/cpu-temperature.lua
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-14 22:50:39 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-14 22:50:39 +0530
commit05da0e10926d4ade3b10a55999a0ed1b797caf65 (patch)
tree97cf6a33e5ce90d57e6894b748b1e18ad690643e /.config/luastatus-scripts-dwm/cpu-temperature.lua
parentf9c150cf57732bb7b42c6b2a5db70039161f8c6d (diff)
added luastatus configHEADmaster
Diffstat (limited to '.config/luastatus-scripts-dwm/cpu-temperature.lua')
-rw-r--r--.config/luastatus-scripts-dwm/cpu-temperature.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/.config/luastatus-scripts-dwm/cpu-temperature.lua b/.config/luastatus-scripts-dwm/cpu-temperature.lua
new file mode 100644
index 0000000..38b25d0
--- /dev/null
+++ b/.config/luastatus-scripts-dwm/cpu-temperature.lua
@@ -0,0 +1,45 @@
+paths = {}
+do
+ -- Replace "*" with "[^0]*" in the first glob if your zeroeth thermal sensor is virtual (and
+ -- thus useless):
+ local f = assert(io.popen([[
+ #for file in /sys/class/thermal/thermal_zone*/temp
+ #do
+ # [ -e "$file" ] || break
+ # printf "%s\n" "$file"
+ #done
+for dir in /sys/class/hwmon/*
+do
+ [ -e "$dir" ] || break
+ IFS= read -r monitor_name < "$dir"/name
+ # You may have more than one hardware monitor enabled
+ # If so, disable ones that are not needed
+ case "$monitor_name" in
+ coretemp|fam15h_power|k10temp)
+ printf "%s\n" "$dir"/temp*_input
+ esac
+done
+]]))
+ for p in f:lines() do
+ table.insert(paths, p)
+ end
+ f:close()
+end
+
+widget = {
+ plugin = 'timer',
+ opts = {period = 2},
+ cb = function()
+ for _, p in ipairs(paths) do
+ local f = assert(io.open(p, 'r'))
+ local temp = f:read('*number') / 1000
+ local icon = ""
+ if temp > 55 then
+ icon = ""
+ elseif temp > 80 then
+ icon = ""
+ end
+ return string.format('%s %.0f°C', icon, temp)
+ end
+ end,
+}