From 3ebb9866ef5bab4829f332ec78f2db0f7bde4d28 Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Mon, 14 Apr 2025 12:11:24 +0900 Subject: [PATCH] feat: add battery_enabled script --- README.md | 11 +++++++++++ battery_enabled.tmux | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100755 battery_enabled.tmux diff --git a/README.md b/README.md index 5bf4775..74bf51c 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/battery_enabled.tmux b/battery_enabled.tmux new file mode 100755 index 0000000..a2b7a75 --- /dev/null +++ b/battery_enabled.tmux @@ -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