r/linux_programming • u/8thdev • Feb 18 '21
Monitor AC status / sysfs
Hi all - I wanted to write a bit of sample code to show the AC charging status using libev and the /sys/class/power_supply/AC/online file.
I was surprised to see that even though the content of the file changed, its 'stat' didn't when I pulled the plug. So the kernel makes the contents of the file change, but doesn't update the timestamp of the sysfs file.
So: is there a way to get the kernel to update the file time?
If not, is there an alternative file which would work with e.g. libev ?
3
Upvotes
View all comments
Show parent comment
2
u/8thdev Feb 19 '21
Thank you; I hadn't realized the data was generated at read time. That makes perfect sense.
I'm now writing an interface to libudev for my 8th programming language so I can make that sample work as intended.
Thank you very much!