plugin/battery: bug fix

When `upower --enumerate | grep -i BAT` returns multiple lines of results (which are file paths),
the added quotation (from commit 3cb5f3f7e6) concatenates them all to provide an invalid path.
Thus to make the plugin work as before the commit,
take only the first line of the results.
pull/2074/head
Nariyasu Heseri 2022-01-29 03:17:50 +09:00
parent 7e79212dff
commit b87f3067b5
1 changed files with 3 additions and 3 deletions

View File

@ -3,7 +3,7 @@ about-plugin 'display info about your battery charge level'
function ac_adapter_connected() { function ac_adapter_connected() {
if _command_exists upower; then if _command_exists upower; then
upower -i "$(upower -e | grep -i BAT)" | grep 'state' | grep -q 'charging\|fully-charged' upower -i "$(upower -e | grep -i BAT | head -n 1)" | grep 'state' | grep -q 'charging\|fully-charged'
elif _command_exists acpi; then elif _command_exists acpi; then
acpi -a | grep -q "on-line" acpi -a | grep -q "on-line"
elif _command_exists pmset; then elif _command_exists pmset; then
@ -17,7 +17,7 @@ function ac_adapter_connected() {
function ac_adapter_disconnected() { function ac_adapter_disconnected() {
if _command_exists upower; then if _command_exists upower; then
upower -i "$(upower -e | grep -i BAT)" | grep 'state' | grep -q 'discharging' upower -i "$(upower -e | grep -i BAT | head -n 1)" | grep 'state' | grep -q 'discharging'
elif _command_exists acpi; then elif _command_exists acpi; then
acpi -a | grep -q "off-line" acpi -a | grep -q "off-line"
elif _command_exists pmset; then elif _command_exists pmset; then
@ -36,7 +36,7 @@ function battery_percentage() {
local command_output="no" local command_output="no"
if _command_exists upower; then if _command_exists upower; then
command_output=$(upower --show-info "$(upower --enumerate | grep -i BAT)" | grep percentage | grep -o "[0-9]\+" | head -1) command_output=$(upower --show-info "$(upower --enumerate | grep -i BAT | head -n 1)" | grep percentage | grep -o "[0-9]\+" | head -1)
elif _command_exists acpi; then elif _command_exists acpi; then
command_output=$(acpi -b | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}') command_output=$(acpi -b | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}')
elif _command_exists pmset; then elif _command_exists pmset; then