#batlvl.sh# This simple shell script will output a summarized battery status on Linux by utilizing the output of the upower command.
$ batlvl.sh
Battery level: 94% (charging)
#!/bin/sh | |
upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep 'percentage\|state' | sed ':a;N;$!ba;s/\s\{1,\}state\:\s\{1,\}\(.*\)\n\s\{1,\}percentage\:\s\{1,\}\(.*\)/Battery level: \2 (\1)/' |
#batlvl.sh# This simple shell script will output a summarized battery status on Linux by utilizing the output of the upower command.
$ batlvl.sh
Battery level: 94% (charging)