lcpz / lain

Awesome WM complements
GNU General Public License v2.0
1.06k stars 212 forks source link

Cannot get temperature of a tempfile on widget but with cat I can #498

Open gcarlos64 opened 3 years ago

gcarlos64 commented 3 years ago

Hi, I'm trying to use the temperature widget but get only "N/A" temperature. My widget config is:

   timeout = 5,
   tempfile = "/sys/class/hwmon/hwmon1/temp1_input",
   settings = function()
       widget:set_markup("<span foreground='#F0544C'> CPU_TEMP:</span> " .. coretemp_now .. "°C ");
   end

When I cat this tempfile I get the correct temperature of my CPU (I got this tempfile over lm-sensor "debug"). My widget works when the tempfile is on /sys/devices/virtual/thermal/thermal_zone* path, but don't have any temp file of my cpu and gpu over here.

Awesome and lua versions:

awesome v4.3 (Too long)
 • Compiled against Lua 5.3.5 (running with Lua 5.3)
 • D-Bus support: ✔
 • execinfo support: ✔
 • xcb-randr version: 1.6> gdfsg
 • LGI version: 0.9.2
$ lua -v
Lua 5.4.2  Copyright (C) 1994-2020 Lua.org, PUC-Rio> gdfsg

So, I don't know if it's a bug or if I did something wrong, so sorry if it's not pertinent. Since now, thanks for the help!

bzgec commented 3 years ago

Hello,

can you please show output of the cat /sys/class/hwmon/hwmon1/temp1_input command?

I used this command to find temperature files: find /sys/devices -type f -name *temp*. My output is:

/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon3/temp1_label
/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon3/temp2_label
/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon3/temp1_input
/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon3/temp2_input
/sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/hwmon/hwmon2/temp1_label
/sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/hwmon/hwmon2/temp1_crit
/sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/hwmon/hwmon2/temp1_alarm
/sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/hwmon/hwmon2/temp1_input
/sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/hwmon/hwmon2/temp1_min
/sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/hwmon/hwmon2/temp1_max
/sys/devices/pci0000:00/0000:00:08.1/0000:05:00.0/hwmon/hwmon5/temp1_label
/sys/devices/pci0000:00/0000:00:08.1/0000:05:00.0/hwmon/hwmon5/temp1_input
/sys/devices/virtual/thermal/thermal_zone0/trip_point_5_temp
/sys/devices/virtual/thermal/thermal_zone0/trip_point_4_temp
/sys/devices/virtual/thermal/thermal_zone0/hwmon4/temp1_input
/sys/devices/virtual/thermal/thermal_zone0/trip_point_3_temp
/sys/devices/virtual/thermal/thermal_zone0/trip_point_2_temp
/sys/devices/virtual/thermal/thermal_zone0/trip_point_1_temp
/sys/devices/virtual/thermal/thermal_zone0/temp
/sys/devices/virtual/thermal/thermal_zone0/trip_point_7_temp
/sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp
/sys/devices/virtual/thermal/thermal_zone0/trip_point_6_temp

I figured out that the temperature file I am looking for is /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon3/temp1_input so this is my configuration in theme.lua:

theme.lua
-------------------------------------------------------------------------------------------------------------
local tempicon = wibox.widget.imagebox(theme.widget_temp)
local temp = lain.widget.temp({
    timeout = 10,
    -- Run: `find /sys/devices -type f -name *temp*`
    tempfile = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon3/temp1_input",  -- AMD CPU
    settings = function()
        widget:set_markup(markup.font(theme.font, " " .. math.ceil(coretemp_now) .. "°C "))
    end
})

Output of my temperature file:

cat /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon3/temp1_input
--------------------------------------------------------------------------------------------------
48875
gcarlos64 commented 3 years ago

@bzgec This is the cat of my temperature file:

cat /sys/class/hwmon/hwmon1/temp1_input
--------------------------------------------------------------------
40000

I tried your find command and filtered files that value equals to my /sys/class/hwmon/hwmon1/temp1_input. I just realize that the file /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input have the same value of the previous. I put this one in my widget config and it worked.

But now, I just only doubt why the first file didn't work appropriately... This issue can be closed, I kept it open in hope of someone explain me my doubt.

And Thanks for your help!!!!!

ryukinix commented 10 months ago

@gcarlos64 I had the same problem and I somehow, reading the lain code and digging into kernel file descriptors, solved it in the same way.

Some system information:

awesome v4.3 (Too long)
 • Compiled against Lua 5.3.6 (running with Lua 5.3)
 • D-Bus support: ✔
 • execinfo support: ✔
 • xcb-randr version: 1.6
 • LGI version: 0.9.2
Lua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio

Screenshot_2024-01-06_01-19-11