Merge pull request #976 from shinenelson/battery-upower

Battery upower
pull/979/head
Nils Winkler 2017-06-11 15:24:53 +02:00 committed by GitHub
commit 1fda6a6af5
1 changed files with 15 additions and 3 deletions

View File

@ -2,7 +2,11 @@ cite about-plugin
about-plugin 'display info about your battery charge level' about-plugin 'display info about your battery charge level'
ac_adapter_connected(){ ac_adapter_connected(){
if command_exists acpi; if command_exists upower;
then
upower --show-info $(upower --enumerate | grep BAT) | grep --quiet state | grep --quiet charging
return $?
elif command_exists acpi;
then then
acpi -a | grep -q "on-line" acpi -a | grep -q "on-line"
return $? return $?
@ -18,7 +22,11 @@ ac_adapter_connected(){
} }
ac_adapter_disconnected(){ ac_adapter_disconnected(){
if command_exists acpi; if command_exists upower;
then
upower --show-info $(upower --enumerate | grep BAT) | grep --quiet state | grep --quiet discharging
return $?
elif command_exists acpi;
then then
acpi -a | grep -q "off-line" acpi -a | grep -q "off-line"
return $? return $?
@ -37,7 +45,11 @@ battery_percentage(){
about 'displays battery charge as a percentage of full (100%)' about 'displays battery charge as a percentage of full (100%)'
group 'battery' group 'battery'
if command_exists acpi; if command_exists upower;
then
local UPOWER_OUTPUT=$(upower --show-info $(upower --enumerate | grep BAT) | grep percentage | tail --bytes 5)
echo ${UPOWER_OUTPUT: : -1}
elif command_exists acpi;
then then
local ACPI_OUTPUT=$(acpi -b) local ACPI_OUTPUT=$(acpi -b)
case $ACPI_OUTPUT in case $ACPI_OUTPUT in