dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 292cecd7150e23e712fa62346e18a111c78f3d5f
parent 6b08ec5d6f7ab76dd09eb2011ee79b6024485455
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Thu,  1 Feb 2018 20:09:31 -0500

Posix shell compliance for Tmux battery indicator

Diffstat:
M.local/lib/tmux/battery_indicator.sh | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/.local/lib/tmux/battery_indicator.sh b/.local/lib/tmux/battery_indicator.sh @@ -1,17 +1,18 @@ -#!/usr/bin/env bash -# modified from http://ficate.com/blog/2012/10/15/battery-life-in-the-land-of-tmux/ - +#!/bin/sh +# +# ~/.local/lib/tmux/battery_indicator.sh +# SMILE='☻ ' -charged_slots=$(echo "`my battery percent`/30+1" | bc -l | cut -d '.' -f 1) -if [[ $charged_slots -gt 3 ]]; then - charged_slots=3 -fi +battery_percent=`my battery percent` +charged_slots=`echo "$battery_percent/30+1" | bc -l | cut -d '.' -f 1` +[ $charged_slots -gt 3 ] && charged_slots=3 echo -n '#[fg=colour108]' for i in `seq 1 $charged_slots`; do echo -n "$SMILE"; done -if [[ $charged_slots -lt 3 ]]; then +if [ $charged_slots -lt 3 ]; then echo -n '#[fg=colour131]' - for i in `seq 1 $(echo "3-$charged_slots" | bc)`; do echo -n "$SMILE"; done + uncharged_slots=`echo "3-$charged_slots" | bc` + for i in `seq 1 $uncharged_slots`; do echo -n "$SMILE"; done fi