waybar: scan sysfs for CPU hwmon

This commit is contained in:
LordMZTE 2024-08-23 22:04:25 +02:00
parent 45ad0a5c8b
commit d6008d9d17
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
3 changed files with 16 additions and 4 deletions

View file

@ -1,5 +1,19 @@
;<! tmpl:setPostProcessor(opt.fennelToJSON) !>
;; vim: ft=fennel
<!
local cpu_temp_hwmon = nil
for d in require("lfs").dir("/sys/class/hwmon") do
if d ~= "." and d ~= ".." then
local namef = io.open("/sys/class/hwmon/" .. d .. "/name", "r")
if namef:read("*a"):gsub("%s+", "") == "coretemp" then
cpu_temp_hwmon = "/sys/class/hwmon/" .. d .. "/temp1_input"
end
namef:close()
end
end
!>
(local format-icons ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"])
{:spacing 4
@ -41,7 +55,7 @@
:interval 2
: format-icons}
:memory {:format "{}% "}
:temperature {:hwmon-path "<% opt.cpu_temp_hwmon %>"
:temperature {:hwmon-path "<% cpu_temp_hwmon %>"
:critical-threshold 80
:format "{temperatureC}°C {icon}"
:format-icons ["" "" ""]}

View file

@ -47,9 +47,6 @@ opts.cursor = {
size = 24,
}
-- hwmon temperature path for CPU temp used by waybar
opts.cpu_temp_hwmon = "/sys/class/hwmon/hwmon0/temp1_input"
opts.gtk_theme = "catppuccin-mocha-red-standard"
opts.icon_theme = "candy-icons"

View file

@ -37,6 +37,7 @@
libGL
libgit2
luajit
luajitPackages.luafilesystem
pkg-config
racket
roswell