Skip to content

Commit 3ebb986

Browse files
committed
feat: add battery_enabled script
1 parent 48fae59 commit 3ebb986

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ Status Icons:
144144
- attached (`@batt_icon_status_attached`): '⚠️'
145145
- unknown (`@batt_icon_status_unknown`): '?'
146146

147+
#### Enabled
148+
149+
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.
150+
151+
```tmux
152+
run-shell ~/clone/path/battery_enabled.tmux
153+
# for example, if using catppuccin:
154+
set -agF status-right "#{?#{#{==:#{E:@battery_exists},true}},#{E:@catppuccin_status_battery},}"
155+
run-shell ~/clone/path/battery.tmux
156+
```
157+
147158
#### Changing the Defaults
148159

149160
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:

battery_enabled.tmux

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
source "$CURRENT_DIR/scripts/helpers.sh"
6+
7+
main() {
8+
tmux set-option -gq "@battery_exists" "$( [ -n "$(battery_status)" ] && echo true || echo false )"
9+
}
10+
main

0 commit comments

Comments
 (0)