feat: add battery_enabled script (#118)

This commit is contained in:
Julian Grinblat 2025-12-30 23:58:56 +09:00 committed by GitHub
parent 65b0c5261b
commit e3b7fe0641
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View file

@ -144,6 +144,17 @@ Status Icons:
- attached (`@batt_icon_status_attached`): '⚠️'
- unknown (`@batt_icon_status_unknown`): '?'
#### Enabled
If you run `battery_enabled.tmux` from the top-level of the repo, it will setup a `@battery_enabled` variable, that can be used to selectively display the battery based on whether or not a battery is available or not.
```tmux
run-shell ~/clone/path/battery_enabled.tmux
# for example, if using catppuccin:
set -agF status-right "#{?#{#{==:#{E:@battery_exists},true}},#{E:@catppuccin_status_battery},}"
run-shell ~/clone/path/battery.tmux
```
#### Changing the Defaults
All efforts have been made to make sane defaults, but if you wish to change any of them, add the option to `.tmux.conf`. For example:

10
battery_enabled.tmux Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/helpers.sh"
main() {
tmux set-option -gq "@battery_exists" "$( [ -n "$(battery_status)" ] && echo true || echo false )"
}
main