On Fri, Sep 02, 2016 at 11:46:27PM BST, Aioi Yuuko wrote:
> Hi,
>
> I'm trying to wean myself off external packages as much as possible.
> Is there a common, accepted way of viewing, for instance, battery
> life, with only included programs?
Hi Aioi,
There's the already mentioned apm(8) (i.e. -l, -m options) or you
could run something like this:
#!/bin/sh
sysctl -n hw.sensors.acpiac0.indicator0 \
hw.sensors.acpibat0.watthour0 \
hw.sensors.acpibat0.watthour3 | awk 'NR == 1 { ac = $1 }
NR == 2 { full = $1 }
NR == 3 { remaining = $1 }
END { if ( ac == "On" )
state = "charging"
else
state = "discharging"
printf("%s %d%s %s%s\n", "Remaining battery life is",
remaining/full*100, "% and it is", state, "\.") }'
Regards,
Raf