Open utkarsh2102 opened 3 years ago
Hm, looks like this could work:
# utkarsh @ utkarsh2102 in ~ [1:54:20]
$ irb
irb(main):001:0> require "find"
=> true
irb(main):002:0> Find.find('/sys/class/power_supply/').grep(/BAT/)
=> ["/sys/class/power_supply/BAT0"]
Likely you never had this in mind. I'd like to use this on an linux phone. There isn't any BAT* under power_supply. On the pine phone pro there are three directories there:
rk818-battery (with 4 more dirs under that and other subdirs under those with more files under each)
rk818-usb (similar dir sub-structure as above)
tcpm-source-psy-4-002 (similar dir sub-structure as above)
The phone is running Mobian, which is debian bookworm with a custom gnome shell. The phone does display notifications and I've written scripts using notify-send that work fine.
Faced the same issue on my machine after installing from the latest commit.
Okay, I am going to use upower
to fix this on the laptop/machine side. I still need to look at the pine phone thingy separately.
@utkarsh2102 might I suggest k-nowicki/rupower
as the Ruby interface for upower
?
From debbug #988091:
...which is true! See here: https://github.com/utkarsh2102/batalert/blob/703e816bcecfe56962f5cc91c041164cb9425c68/lib/batalert.rb#L14-L18
Probably worth figuring out which
BAT*
is there separately? Maybe I'll go ahead and re-write this in a much better way.