Update battery.plugin to check for acpi existence

pull/41/head
Jesus de Mula Cano 2011-03-07 00:05:54 +01:00
parent 229aa833a2
commit 1080af358d
1 changed files with 27 additions and 19 deletions

View File

@ -1,24 +1,29 @@
#!/bin/bash #!/bin/bash
# pmset -g batt
battery_percentage(){ battery_percentage(){
local ACPI_OUTPUT=$(acpi -b) if command_exists acpi;
case $ACPI_OUTPUT in then
*" Unknown"*) local ACPI_OUTPUT=$(acpi -b)
echo $ACPI_OUTPUT | head -c 22 | tail -c 2 case $ACPI_OUTPUT in
;; *" Unknown"*)
*" Discharging"*) echo $ACPI_OUTPUT | head -c 22 | tail -c 2
echo $ACPI_OUTPUT | head -c 26 | tail -c 2 ;;
;; *" Discharging"*)
*" Charging"*) echo $ACPI_OUTPUT | head -c 26 | tail -c 2
echo $ACPI_OUTPUT | head -c 23 | tail -c 2 ;;
;; *" Charging"*)
*" Full"*) echo $ACPI_OUTPUT | head -c 23 | tail -c 2
echo '99' ;;
;; *" Full"*)
*) echo '99'
echo '-1' ;;
;; *)
esac echo '-1'
;;
esac
else
echo "no"
fi
} }
battery_charge(){ battery_charge(){
@ -34,6 +39,9 @@ battery_charge(){
local BATTERY_PERC=$(battery_percentage) local BATTERY_PERC=$(battery_percentage)
case $BATTERY_PERC in case $BATTERY_PERC in
no)
echo ""
;;
9*) 9*)
echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${normal}" echo "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${normal}"
;; ;;