Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johann Dreo
liquidprompt
Commits
e95618b4
Commit
e95618b4
authored
Oct 21, 2021
by
Slobodan Todorov
Browse files
Update documentation and tests for LP_BATTERY_ID option
parent
ef944b41
Changes
5
Hide whitespace changes
Inline
Side-by-side
docs/config.rst
View file @
e95618b4
...
...
@@ -187,6 +187,20 @@ General
Features
--------
.. attribute:: LP_BATTERY_ID
:type: int
:value: 0
Select which battery to use when monitoring level and charging status.
Works only with ACPI method of obtaining battery information.
Usage example:
* Default value for this option is ``0``, meaning default battery will
be used when monitoring battery level and charging status.
* Any other value must be a valid battery ID. Can be obtained by running
``acpi --battery`` and getting the appropriate ID from the printout.
.. versionadded:: 2.1
.. attribute:: LP_DELIMITER_KUBECONTEXT_PREFIX
:type: string
...
...
docs/functions/data.rst
View file @
e95618b4
...
...
@@ -44,6 +44,9 @@ Battery
Can be disabled by :attr:`LP_ENABLE_BATT`.
.. versionchanged:: 2.1
:attr:`LP_BATTERY_ID` can be used to specify which battery to monitor.
Development Environment
-----------------------
...
...
liquidprompt
View file @
e95618b4
...
...
@@ -2352,6 +2352,7 @@ case "$LP_OS" in
# Find the desired battery by it's ID
if [[
$line
=~ Battery
\
$LP_BATTERY_ID
]]; then
acpi=
$line
# Use only desired battery output
break
fi
done <<<"
$acpi
"
fi
...
...
liquidpromptrc-dist
View file @
e95618b4
...
...
@@ -20,7 +20,7 @@
# Recommended value is 75
LP_BATTERY_THRESHOLD
=
75
# Use particular battery IDwhen multiple batteries are reported by ACPI
# Use particular battery ID
when multiple batteries are reported by ACPI
# and the default one is wrong.
# Example of such behaviour is when using Logitech Unified Receiver
# and ACPI reports keyboard and mouse batteries first, and laptop battery last
...
...
tests/test_acpi.sh
View file @
e95618b4
...
...
@@ -10,7 +10,7 @@ unset -f uname
LP_ENABLE_BATT
=
1
typeset
-a
battery_outputs battery_statuses battery_values temp_outputs temp_values
typeset
-a
battery_outputs battery_statuses battery_values temp_outputs temp_values
battery_ids
# Add test cases to these arrays like below
...
...
@@ -19,6 +19,7 @@ battery_outputs+=(
""
)
battery_statuses+
=(
4
)
battery_ids+
=(
""
)
battery_values+
=(
""
)
temp_outputs+
=(
"Thermal 0: ok, 23.0 degrees C"
...
...
@@ -31,11 +32,26 @@ battery_outputs+=(
)
battery_statuses+
=(
0
)
battery_values+
=(
55
)
battery_ids+
=(
0
)
temp_outputs+
=(
"Thermal 0: ok, -267.8 degrees C"
)
temp_values+
=(
-267
)
# Multiple batteries
battery_outputs+
=(
"Battery 0: Discharging, 0%, rate information unavailable
Battery 1: Discharging, 0%, rate information unavailable
Battery 2: Discharging, 53%, 02:35:00 remaining"
)
battery_statuses+
=(
0
)
battery_values+
=(
53
)
battery_ids+
=(
2
)
temp_outputs+
=(
"Thermal 0: ok, 39.0 degrees C"
)
temp_values+
=(
39
)
# VPS at OVH
temp_outputs+
=(
""
...
...
@@ -50,6 +66,7 @@ function test_acpi_battery {
for
((
index
=
0
;
index <
${#
battery_values
[@]
}
;
index++
))
;
do
__battery_output
=
${
battery_outputs
[
$index
]
}
LP_BATTERY_ID
=
${
battery_ids
[
$index
]
}
LP_BATTERY_THRESHOLD
=
100
_lp_battery
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment