564a708d6af90b1bc5bf4d13e7ad80abca92ad74

Author
Thiago Perrotta <thiagoperrotta95@gmail.com>
Committer
Thiago Perrotta <thiagoperrotta95@gmail.com>
Date

Message

added the linux implementation to the battery plugin

Diff

 1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
 2index 16ad3e6510a6937f528fb120740bc4efcfd592d5..670c6a47defc70742a455e3a49d206c639318e1f 100644
 3--- a/plugins/battery/battery.plugin.zsh
 4+++ b/plugins/battery/battery.plugin.zsh
 5@@ -58,9 +58,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@@ -86,15 +96,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() {