Files
dotfiles/home/.tmux/battery.sh
Andrejus 8138d44c73 Replace red with amber, unify palette, add fetch/pull aliases
- Add git aliases: f (fetch), p (pull) and shell aliases: gf, gp
- Replace all #F40404 (red) with #F88C14 (amber) across prompt, gitconfig,
  vim, bat theme, and tmux scripts for colourblind-friendly palette
- Standardise hex case to uppercase throughout
- Unify #728cb8 → #7290B8 (fix blue inconsistency)
- Replace unique #8787AF with palette #7290B8 in gitconfig
- Remove unused red colour definition from prompt.zsh
- Update dark diff backgrounds from red-tinted to amber-tinted

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-25 17:38:47 +00:00

42 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Battery indicator for tmux status bar.
# 󰚥 AC when full/plugged, 󰂄 charging with %, amber 󰂃 when <=20%.
pct=""
charging=""
full=""
if command -v pmset &>/dev/null; then
# macOS
info=$(pmset -g batt)
pct=$(echo "$info" | grep -o '[0-9]\+%' | head -1 | tr -d '%')
echo "$info" | grep -q 'AC Power' && charging=1
echo "$info" | grep -q 'charged\|finishing charge' && full=1
elif [[ -f /sys/class/power_supply/BAT0/capacity ]]; then
# Linux
pct=$(cat /sys/class/power_supply/BAT0/capacity)
status=$(cat /sys/class/power_supply/BAT0/status)
[[ "$status" == "Charging" ]] && charging=1
[[ "$status" == "Full" || "$status" == "Not charging" ]] && full=1
fi
[[ -z "$pct" ]] && exit 0
if [[ -n "$full" ]]; then
echo "#[fg=#808080]󰚥 AC#[default]"
elif [[ -n "$charging" ]]; then
echo "#[fg=#808080]󰂄 ${pct}%#[default]"
elif (( pct <= 10 )); then
echo "#[fg=#F88C14,bold]󰂎 ${pct}%#[default]"
elif (( pct <= 20 )); then
echo "#[fg=#F88C14,bold]󰁺 ${pct}%#[default]"
elif (( pct <= 40 )); then
echo "#[fg=#808080]󰁼 ${pct}%#[default]"
elif (( pct <= 60 )); then
echo "#[fg=#808080]󰁾 ${pct}%#[default]"
elif (( pct <= 80 )); then
echo "#[fg=#808080]󰂀 ${pct}%#[default]"
else
echo "#[fg=#808080]󰁹 ${pct}%#[default]"
fi