From daa16bf3603206c64cc8f6d734ba4bdea095ff7f Mon Sep 17 00:00:00 2001 From: David Runge Date: Fri, 11 Mar 2016 12:49:16 +0100 Subject: bin/get_battery_status: Adding condition to check if there's actually a battery to show. --- bin/get_battery_status | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'bin/get_battery_status') diff --git a/bin/get_battery_status b/bin/get_battery_status index 5ad18ce..bc4b819 100755 --- a/bin/get_battery_status +++ b/bin/get_battery_status @@ -15,11 +15,13 @@ if [ -x /usr/bin/acpi ]; then battery_percentage=$(echo $acpi_output|cut -d' ' -f4) battery_percentage=${battery_percentage%","} battery_percentage=${battery_percentage%"%"} - if [ $battery_state = "Discharging" ]; then - battery_remaining=$(echo $acpi_output|cut -d' ' -f5) - echo "$battery_percentage% ($battery_remaining)" - else - echo "$battery_percentage%" + if [ $battery_number -ge 0 ]; then + if [ $battery_state = "Discharging" ]; then + battery_remaining=$(echo $acpi_output|cut -d' ' -f5) + echo "$battery_percentage% ($battery_remaining)" + else + echo "$battery_percentage%" + fi fi else exit 1 -- cgit v1.2.3-70-g09d2