r/linux_programming • • 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

5 comments sorted by

View all comments

Show parent comment

1

u/8thdev Feb 18 '21

Ah, I was afraid that was the case. So my sample code is useless for this particular use-case.

Thanks!