Battery info + RGB led battery state script

When playing with my PinePhone, I re-wrote a script I did ages ago for the pine64 so that it drives the RGB (Red Green Blue) notification led on the pinephone to indicate the battey state... i.e. less than 33% is red, 34 to 66% is yellow (red and green), and 67 to 100% is green. Has some other bits in it, and will probably end up replacing the original script at, but not there yet.

Only made possible because the Manjaro builds already expose the sysfs nodes for controlling the LEDs, even at this early stage, ready for the end user to do with it as they please! :wink:


Very nice.
To use this, it should jus be started automatically at boot or is it only possible at user login?

1 Like

Thanks :slight_smile: That's next on my list to check. Systemd and me have never gotten along (bar a oneshot unit I did) so now need to write a unit that allows this to start (and remain resident), and see what breaks.

For just showing battery info, no extra permissions are needed, but changing the led state is a different matter. Unfortunately, sysfs gpios always seem to be root:root with read only permissions for group and everyone, rather than root:gpio with write permission for the group, so I either need to do the same as I did for another script, and have a one-shot unit do a chown & chmod to the three led sysfs led folders - e.g. - unit - script - and then it can be run at the user level, or it needs to run as a root user right from the start.

Right, so now that the display is currently MIA, time to play with this again :wink:

With the following systemd unit installed to /etc/systemd/system/batteryChecker.service, and the main script installed to /usr/local/sbin/ it works fine on boot up, and can be stopped via systemd also.

Description=batteryChecker LED notifier

ExecStart=/usr/local/sbin/ -d


This is now in my normal pine64-scripts repo so can be easily/directly downloaded from there. There's also another script that fixes up the display brightness if it's turned down by the dumb systemd-backlight service (or at least it seems to work!).

1 Like

Nice Work.

Regarding the Screen Backlight, a new parameters are being used in the updated kernel so hopefully the backlight will not go below the minimum where user can still see the screen on.

Regarding the Wifi script, Is it for BH edition ?


Nice :slight_smile:

Yes, or at least it seems to do 'something' on the BH edition. However, I've had more luck simply leaving a second tmux session pinging something else on the network periodically (5 second intervals) so far... twiddling the power saving registers did seem to have some effect, but didn't seem as reliable long term, but did make the back warm up nicely still.

This topic was automatically closed after 90 days. New replies are no longer allowed.

Forum kindly sponsored by