diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-21 19:53:57 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-21 19:53:57 +0100 |
commit | e856077705c7aae219313bd1927fafc07ec00151 (patch) | |
tree | 043034ef1091c0bc08b77ef70ab3eb902ad2ed04 /modules | |
parent | a87e9dff442349acbc3656ec64fabd6ec286e888 (diff) |
Added battery module
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/battery | 35 | ||||
-rwxr-xr-x | modules/bluetooth | 2 |
2 files changed, 37 insertions, 0 deletions
diff --git a/modules/battery b/modules/battery new file mode 100755 index 0000000..fa9d373 --- /dev/null +++ b/modules/battery @@ -0,0 +1,35 @@ +#!/bin/bash + +get_battery() +{ + if [ -d /sys/class/power_supply/BAT? ]; then + ac_adapter=$(cat /sys/class/power_supply/BAT?/status) + if [ "$ac_adapter" == "Charging" ]; then + echo "" + fi + + # Will show all batteries with approximate icon for remaining power. + for x in /sys/class/power_supply/BAT?/capacity; + do + case "$(cat $x)" in + 100) echo "" ;; + 9[0-9]) echo " $(cat $x)%" ;; + 8[0-9]|7[0-9]) echo " $(cat $x)%" ;; + 6[0-9]|5[0-9]) echo " $(cat $x)%" ;; + 4[0-9]|3[0-9]) echo " $(cat $x)%" ;; + 2[0-9]|1[0-9]) if [ "$ac_adapter" == "Charging" ]; then + echo " $(cat $x)%" + else + echo " $(cat $x)%" + fi ;; + [0-9]) if [ "$ac_adapter" == "Charging" ]; then + echo " $(cat $x)%" + else + echo " $(cat $x)%" + fi ;; + esac + done + fi +} + +get_battery diff --git a/modules/bluetooth b/modules/bluetooth index e342d5f..88a7a56 100755 --- a/modules/bluetooth +++ b/modules/bluetooth @@ -17,3 +17,5 @@ get_bluetooth() #echo "" fi } + +get_bluetooth |