Hello, is there a way to check battery level of the L5 through SSH?
You should be able to query the battery level from sysfs.
See also:
Thanks! it works! Would be great to have at the initial page also the battery level, something like what armbian has.
Have you tried the Show Battery Percentage option in the Power section of the Settings app?
Yes, it’s on. But I mean from SSH, like here:
Linux pureos 6.3.0-1-librem5 #1 SMP PREEMPT Wed Jul 26 18:34:58 UTC 2023 aarch64
The programs included with the PureOS system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
PureOS comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Sep 24 10:30:11 2023 from 192.168.1.xxx
purism@pureos:~$
Thanks for clarifying. What exactly were you referring to when you mentioned “initial page?”
Probably related to the text that shows up when starting a login shell (via ssh), Armbian by default has a bunch of scripts that run and show a lot of system info.
fch - this is a Linux system, so you can hack up your own solution, as well I might try my hand at it…
so you can put any command in $HOME/.profile (there are probably a lot already by default), and they will run when you run a new login shell (but not a new subshell). That should get you started
Yes Lliure, that what pajuky answered.
Try “inxi -B” at the command prompt.
Or perhaps it would be nice if bash
were extended so that PS1 had a backslash sequence for battery level.
It can be. I’ll have to dig out my PinePhone where I had done exactly that, so that I can copy that code onto my L5 (and hhere)
(ok so it’s not an extension straight into bash, but you can have it work anyway)
ok, no need to dig out my Pinephone. The code was lifted straight from the Mobian Wiki:
https://wiki.mobian-project.org/doku.php?id=tweaks#bash-prompt-shows-battery-state
# -= start battery prompt =-
battery_status(){
BATTERY=/sys/class/power_supply/axp20x-battery #this is for pinephone and pinetab
#BATTERY=/sys/class/power_supply/rk818-battery #this is for pinephone pro
#BATTERY=/sys/class/power_supply/max170xx_battery # this is for librem 5
BATSTATE=$(cat ${BATTERY}/status)
CHARGE=$(cat ${BATTERY}/capacity)
NON='\001\e[0m\002'
BLD='\001\e[1m\002'
RED='\001\e[1;31m\002'
GRN='\001\e[1;32m\002'
YEL='\001\e[1;33m\002'
COLOUR="$RED"
case "${BATSTATE}" in
'Charged')
BATSTT="="
;;
'Charging')
BATSTT="+"
;;
'Not charging'|'Discharging')
BATSTT="-"
;;
*)
BATSTT="*"
;;
esac
# prevent a charge of more than 100% displaying
if [ "$CHARGE" -gt "99" ]
then
CHARGE=100
fi
if [ "$CHARGE" -gt "24" ]
then
COLOUR="$YEL"
fi
if [ "$CHARGE" -gt "34" ]
then
COLOUR="$GRN"
fi
printf "[${BATSTT}${COLOUR}${CHARGE}%%${NON}]"
} #end of battery_status()
if [ $(id -u) -eq 0 ];
then # you are root, set red colour prompt
PS1='$(battery_status)\[\033[1;31m\]\u\[\033[0;32m\]@\h\[\033[1;34m\] \w\[\033[0m\]\$ '
else # normal user
PS1='$(battery_status)\[\033[1;36m\]\u\[\033[0;32m\]@\h\[\033[1;34m\] \w\[\033[0m\]\$ '
fi
# -=end battery prompt=-