23a43e9fd62828b7b80f770080a8efc1fceecc35
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #2574 from thiagowfx/linux-battery
added the linux implementation to the battery plugin
Diff
1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
2index e39cc5b8f455c952f3af876ee9b1e68c397903c3..ae2261ecd250c2ea717f8a0a704e9bff75535bf5 100644
3--- a/plugins/battery/battery.plugin.zsh
4+++ b/plugins/battery/battery.plugin.zsh
5@@ -62,9 +62,19 @@ if [[ $(uname) == "Darwin" ]] ; then
6
7 elif [[ $(uname) == "Linux" ]] ; then
8
9+ function battery_is_charging() {
10+ ! [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
11+ }
12+
13+ function battery_pct() {
14+ echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
15+ }
16+
17 function battery_pct_remaining() {
18- if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
19- echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
20+ if [ ! $(battery_is_charging) ] ; then
21+ battery_pct
22+ else
23+ echo "External Power"
24 fi
25 }
26
27@@ -90,15 +100,6 @@ elif [[ $(uname) == "Linux" ]] ; then
28 fi
29 }
30
31- function battery_pct() {
32- # todo for on linux
33- }
34-
35- function battery_is_charging() {
36- # todo on linux
37- false
38- }
39-
40 else
41 # Empty functions so we don't cause errors in prompts
42 function battery_pct_remaining() {