Added non-acpi battery
This commit is contained in:
parent
cee50311bc
commit
4570003c2b
47
liquidprompt
47
liquidprompt
@ -411,7 +411,7 @@ unset _lp_source_config
|
||||
[[ "$LP_ENABLE_BZR" = 1 ]] && { command -v bzr > /dev/null || LP_ENABLE_BZR=0 ; }
|
||||
case "$LP_OS" in
|
||||
Darwin) [[ "$LP_ENABLE_BATT" = 1 ]] && { command -v pmset >/dev/null || LP_ENABLE_BATT=0 ; };;
|
||||
*) [[ "$LP_ENABLE_BATT" = 1 ]] && { command -v acpi >/dev/null || LP_ENABLE_BATT=0 ; };;
|
||||
*) [[ "$LP_ENABLE_BATT" = 1 ]] && { (command -v upower||command -v acpi) >/dev/null || LP_ENABLE_BATT=0 ; };;
|
||||
esac
|
||||
command -v screen >/dev/null ; _lp_bool _LP_ENABLE_SCREEN $?
|
||||
command -v tmux >/dev/null ; _lp_bool _LP_ENABLE_TMUX $?
|
||||
@ -1111,19 +1111,14 @@ case "$LP_OS" in
|
||||
_lp_battery()
|
||||
{
|
||||
[[ "$LP_ENABLE_BATT" != 1 ]] && return 4
|
||||
local acpi
|
||||
acpi="$(acpi --battery 2>/dev/null)"
|
||||
# Extract the battery load value in percent
|
||||
# First, remove the beginning of the line...
|
||||
local bat="${acpi#Battery *, }"
|
||||
bat="${bat%%%*}" # remove everything starting at '%'
|
||||
bat=$(upower -i /org/freedesktop/UPower/devices/battery_BAT1|grep percentage|awk '{print $2}'|sed 's/%//')
|
||||
|
||||
if [[ -z "${bat}" ]] ; then
|
||||
# not battery level found
|
||||
return 4
|
||||
|
||||
# discharging
|
||||
elif [[ "$acpi" == *"Discharging"* ]] ; then
|
||||
elif [[ $(upower -i /org/freedesktop/UPower/devices/battery_BAT1|grep state|awk '{print $2}') == "discharging" ]] ; then
|
||||
if [[ ${bat} -le $LP_BATTERY_THRESHOLD ]] ; then
|
||||
# under threshold
|
||||
echo -n "${bat}"
|
||||
@ -1146,6 +1141,42 @@ case "$LP_OS" in
|
||||
return 3
|
||||
fi
|
||||
fi
|
||||
# [[ "$LP_ENABLE_BATT" != 1 ]] && return 4
|
||||
# local acpi
|
||||
# acpi="$(acpi --battery 2>/dev/null)"
|
||||
# # Extract the battery load value in percent
|
||||
# # First, remove the beginning of the line...
|
||||
# local bat="${acpi#Battery *, }"
|
||||
# bat="${bat%%%*}" # remove everything starting at '%'
|
||||
#
|
||||
# if [[ -z "${bat}" ]] ; then
|
||||
# # not battery level found
|
||||
# return 4
|
||||
#
|
||||
# # discharging
|
||||
# elif [[ "$acpi" == *"Discharging"* ]] ; then
|
||||
# if [[ ${bat} -le $LP_BATTERY_THRESHOLD ]] ; then
|
||||
# # under threshold
|
||||
# echo -n "${bat}"
|
||||
# return 0
|
||||
# else
|
||||
# # above threshold
|
||||
# echo -n "${bat}"
|
||||
# return 1
|
||||
# fi
|
||||
#
|
||||
# # charging
|
||||
# else
|
||||
# if [[ ${bat} -le $LP_BATTERY_THRESHOLD ]] ; then
|
||||
# # under threshold
|
||||
# echo -n "${bat}"
|
||||
# return 2
|
||||
# else
|
||||
# # above threshold
|
||||
# echo -n "${bat}"
|
||||
# return 3
|
||||
# fi
|
||||
# fi
|
||||
}
|
||||
;;
|
||||
Darwin)
|
||||
|
Loading…
Reference in New Issue
Block a user