shdown / luastatus

universal status bar content generator
GNU General Public License v3.0
293 stars 12 forks source link

Simplifying the battery plugin #52

Closed cdlscpmv closed 5 years ago

cdlscpmv commented 5 years ago
  1. How about removing use_props_naming_scheme and detecting the naming scheme in the plugin itself? It is not hard to do, but it will free the user from the small nuances.

  2. Is there a particular reason not to use uevent? Can it be absent? If not, then maybe the no_uevent option is unnecessary.

I can come up with a pull request, but I think it is better to discuss these things.

shdown commented 5 years ago

It is not hard to do, but it will free the user from the small nuances.

How exactly are you going to do that? Simply checking once if the files are present would be slightly incorrect: the whole device directory may be temporary absent, e.g. when the machine has just been awakened from hibernation or something. (I personally fell into this pitfall when tried to write a script to adjust some power-saving options depending on whether the laptop is on battery or not.)

Can it be absent?

Yes, my older laptop with Linux 3.10 lacked that particular file.

cdlscpmv commented 5 years ago

Simply checking once if the files are present would be slightly incorrect.

It won't incur any significant overhead if we check it every time (that is, the presence of a single file).

Yes, my older laptop with Linux 3.10 lacked that particular file.

Do you think it was caused by the old version of the kernel or by the laptop battery?

shdown commented 5 years ago

It won't incur any significant overhead if we check it every time (that is, the presence of a single file).

I definitely don’t like this. Some form of caching the results would probably be OK, but such a change certainly would not be a “simplification”.

Do you think it was caused by the old version of the kernel or by the laptop battery?

Most likely by the battery driver.

cdlscpmv commented 5 years ago

I definitely don’t like this. Some form of caching the results would probably be OK, but such a change certainly would not be a “simplification”.

One or more files are read on every invocation anyway. Adding one more file to this list doesn't make much difference.

Regarding the uevent file, the same checking mechanism can be applied. It doesn't cost anything in the code, but simplifies the interface. Or maybe it's not worth bothering with the uevent file at all since all that data is available in other files.