mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 22:13:19 -07:00
dynamically shade the battery percentage
This commit is contained in:
parent
9fb7d3c006
commit
9b7923fd3a
1 changed files with 18 additions and 4 deletions
22
bin/battery
22
bin/battery
|
@ -17,7 +17,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
search () {
|
||||
local str expr
|
||||
|
@ -57,13 +57,27 @@ for bat in $BATS; do
|
|||
elif [ "$rem" -lt "$warn" ]; then
|
||||
cap_color="{= yk}"
|
||||
else
|
||||
cap_color="{= Gk}"
|
||||
cap_color="{= gk}"
|
||||
fi
|
||||
|
||||
|
||||
percent=$( echo "$rem" "$full" | awk '{printf "%.0f", 100*$1/$2}')
|
||||
state=$(search "$statefile" "charging state: *\(.*\)")
|
||||
if [ "$percent" -lt 17 ]; then
|
||||
per_color="{= rk}"
|
||||
elif [ "$percent" -lt 33 ]; then
|
||||
per_color="{= Rk}"
|
||||
elif [ "$percent" -lt 50 ]; then
|
||||
per_color="{= yk}"
|
||||
elif [ "$percent" -lt 67 ]; then
|
||||
per_color="{= Yk}"
|
||||
elif [ "$percent" -lt 83 ]; then
|
||||
per_color="{= Gk}"
|
||||
else
|
||||
per_color="{= gk}"
|
||||
fi
|
||||
|
||||
|
||||
state=$(search "$statefile" "charging state: *\(.*\)")
|
||||
case $state in
|
||||
charging)
|
||||
sign="+"
|
||||
|
@ -79,5 +93,5 @@ for bat in $BATS; do
|
|||
;;
|
||||
esac
|
||||
|
||||
printf "\005%s%d%%|%s|\005{-} " "$cap_color" "$percent" "$sign"
|
||||
printf "\005%s%d%%\005{-}\005%s|%s|\005{-} " "$per_color" "$percent" "$cap_color" "$sign"
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue