dotfiles

Luke's GNU/Linux dotfiles for i3, vim, ranger, bash, mpd, etc.
git clone git@git.lukesmith.xyz:dotfiles
Log | Files | Refs | README | LICENSE

commit 9244feb6abb13377963fce969d35e1c75b7c7389
parent ccea275dc8da0c6cc56f6a61ee85e64d528cb7c6
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Sun,  4 Nov 2018 18:56:39 -0500

i3battery compatible with multiple batteries

Diffstat:
M.config/i3blocks/config | 6+++++-
M.scripts/i3battery | 20+++++++++++---------
2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/.config/i3blocks/config b/.config/i3blocks/config @@ -50,7 +50,11 @@ label=🌐 interval=10 [battery] -command=i3battery +command=i3battery BAT1 +interval=5 + +[battery] +command=i3battery BAT0 interval=5 [time] diff --git a/.scripts/i3battery b/.scripts/i3battery @@ -1,20 +1,22 @@ -#!/bin/bash +#!/bin/sh -NUM=`cat /sys/class/power_supply/BAT0/capacity` || exit -STATUS=`cat /sys/class/power_supply/BAT0/status` +# Give a battery name (e.g. BAT0) as an argument. -if [ "$NUM" -ge 80 ]; then +capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit +status=$(cat /sys/class/power_supply/"$1"/status) + +if [ "$capacity" -ge 80 ]; then color="#00FF00" -elif [ "$NUM" -ge 60 ]; then +elif [ "$capacity" -ge 60 ]; then color="#FFFFFF" -elif [ "$NUM" -ge 40 ]; then +elif [ "$capacity" -ge 40 ]; then color="#FFF600" -elif [ "$NUM" -ge 20 ]; then +elif [ "$capacity" -ge 20 ]; then color="#FFAE00" else color="#FF0000" fi -[ "$STATUS" = "Charging" ] && color="#FFF" +[ "$status" = "Charging" ] && color="#FFF" -echo "<span color='$color'>`sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/❓/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g" <<<"$STATUS"` `sed -e 's/$/%/' <<<"$NUM"`</span>" +printf "<span color='%s'>%s %s</span>" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$(echo "$capacity" | sed -e 's/$/%/')"