sudo echo "something" >root_writeable_file does not “work”. I don’t know whether this might have affected your testing.
It doesn’t work because even though
echo is executed as
root, opening the output file is still done as the normal user e.g.
The unpleasant workaround is:
echo "something" | sudo tee root_writeable_file
and you would use
tee -a if you need
>> rather than
However the original command will work if in fact the file is writeable to a normal user, in which case the
sudo is redundant.
I haven’t found where Linux reports this information.
You can get all that from
/sys/class/power_supply/max170xx_battery i.e. a shell script unless that doesn’t mean your usability requirements.
Bear in mind, if comparing the battery charging current with the current reported by the USB multimeter (I have a similar device) that they are two different currents. The Librem 5 is potentially drawing enough current from the power source to charge the battery and run the Librem 5. So they are only the same thing if the Librem 5 is itself drawing no current (so cellular modem and WiFi killed and system sleeping - which right now is not possible! - and also not possible if you intend to record the current going into the battery i.e. Heisenbug).
So typically you might see 1.6A going into the battery but, say, 2A coming in via the USB, with 400 mA being used to run the Librem 5.
For this reason, when I want to look at currents, I typically choose to leave the WiFi on, have the display off, and
ssh in. That is inevitably a compromise.