commit 6c875ad4fdbab444eb175369eb153022f9184a8c
parent 500871674d2eb091ffdcfe4e3e70108a56324a12
Author: Benjamin Chausse <benjamin@chausse.xyz>
Date:   Wed,  4 Nov 2020 17:08:51 -0500

Change battery block in dwmbar

Diffstat:
M.config/nvim/init.vim | 3+++
M.local/bin/dwmbar/dwmb-battery | 41++++++++++++++++++++++-------------------
2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim @@ -291,6 +291,9 @@ nmap <C-Enter> <leader>l " Nvim folding let r_syntax_folding = 1 set foldnestmax=1 +" Arduino settings +let g:arduino_cmd = '/usr/bin/arduino' +let g:arduino_dir = '/usr/share/arduino' " #---Universal Macros---# " diff --git a/.local/bin/dwmbar/dwmb-battery b/.local/bin/dwmbar/dwmb-battery @@ -1,27 +1,30 @@ #!/bin/sh +# Prints all batteries, their percentage remaining and an emoji corresponding +# to charge status. + case $BLOCK_BUTTON in - 1) notify-send -a " Battery" "$(acpi -b)" ;; - 3) notify-send -a " Battery" "$(acpi -V)" ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; + 3) notify-send " Battery module" " : discharging + : not charging + : stagnant charge + : charging + : charged + : battery very low!" ;; esac -# Charging:  # -# Discharching:  # -# Full: underscore:  # -# LOW BATTERY:  # - -batstatus=$(acpi | tail -n 1) +# acpi alternative +# acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, / /;s/[Nn]ot charging, / /;s/[Cc]harging, / /;s/[Uu]nknown, /♻️/;s/[Ff]ull, / /;s/ \(remaining\|until charged\)//"; exit -ico="" - -# Change the underscore color according to the charging state -case "$batstatus" in - *Charging*) ico="  ";; - *Discharging*) ico="  " ;; - *) ico="  " ;; -esac +# Loop through all attached batteries. +for battery in /sys/class/power_supply/BAT? +do + # Get its remaining capacity and charge status. + capacity=$(cat "$battery"/capacity 2>/dev/null) || break + status=$(sed "s/[Dd]ischarging/ /;s/[Nn]ot charging/ /;s/[Cc]harging/ /;s/[Uu]nknown/♻️/;s/[Ff]ull/ /" "$battery"/status) -percentage=$( echo "$batstatus" | sed "s/.*\(\ [0-9]*\)\%.*$/\1/; s/\ //g; 1q") + # If it is discharging and 25% or less, we will add a  as a warning. + [ "$capacity" -le 25 ] && [ "$status" = " " ] && warn=" " -echo "$ico$percentage% " + printf "%s%s%s%% " " $status" "$warn" "$capacity" + unset warn +done | sed 's/ *$//'