feat(battery): add battery module

This commit is contained in:
Valentin Uveges 2023-08-10 08:04:52 +03:00
parent 322db16862
commit 79229bd979
2 changed files with 59 additions and 15 deletions

View file

@ -19,20 +19,18 @@
1. [Themes](#themes) 1. [Themes](#themes)
2. [Installation](#installation) 2. [Installation](#installation)
3. [Status line themes](#status-line-themes) 3. [Overview](#overview)
1. [Default](#default)
2. [Pill](#pill-shape)
3. [Powerline](#powerline)
4. [Powerline with icons](#powerline-with-icons)
5. [No patched fonts](#no-patched-fonts)
4. [Configuration options](#configuration-options) 4. [Configuration options](#configuration-options)
1. [Enable window tabs](#enable-window-tabs) 1. [Window](#window)
2. [Configure separators](#configure-separator) 2. [Window default](#window-default)
3. [Enable date and time](#enable-datetime) 3. [Status](#status)
4. [Enable user](#enable-user) 4. [Customizing modules](#customizing-modules)
5. [Enable host](#enable-host) 5. [Battery module](#battery-module)
6. [Customize icons](#customize-icons) 5. [Configuration Examples](#configuration-examples)
1. [Config 1](#config-1)
2. [Config 2](#config-2)
3. [Config 3](#config-3)
## Themes ## Themes
- 🌻 [Latte](./catppuccin-latte.tmuxtheme) - 🌻 [Latte](./catppuccin-latte.tmuxtheme)
@ -68,8 +66,8 @@ set -g @catppuccin_flavour 'latte' # or frappe, macchiato, mocha
2. Reload Tmux by either restarting the session or reloading it with `tmux source-file ~/.tmux.conf` 2. Reload Tmux by either restarting the session or reloading it with `tmux source-file ~/.tmux.conf`
## Overview ## Overview
![Default](./assets/overview.png)
![Default](./assets/overview.png)
This is a diagram on how the theme is split between it's components. This is a diagram on how the theme is split between it's components.
## Configuration options ## Configuration options
@ -119,7 +117,7 @@ Values:
- yes - this will replace the windows status text with icons - yes - this will replace the windows status text with icons
- no - this will keep the windows status in text format - no - this will keep the windows status in text format
### Override windows status icons #### Override windows status icons
```sh ```sh
set -g @catppuccin_icon_window_last "󰖰" set -g @catppuccin_icon_window_last "󰖰"
set -g @catppuccin_icon_window_current "󰖯" set -g @catppuccin_icon_window_current "󰖯"
@ -223,6 +221,7 @@ Available modules:
- user - display the username - user - display the username
- host - display the hostname - host - display the hostname
- date_time - display the date and time - date_time - display the date and time
- [battery](#battery-module) - display the battery
### Customizing modules ### Customizing modules
@ -243,6 +242,28 @@ set -g @catppuccin_[module_name]_color" "color"
set -g @catppuccin_[module_name]_text" "text" set -g @catppuccin_[module_name]_text" "text"
``` ```
### Battery module
#### Requirements
This module depends on [tmux-battery](https://github.com/tmux-plugins/tmux-battery/tree/master).
#### Install
The prefered way to install tmux-battery is using [TPM](https://github.com/tmux-plugins/tpm).
#### Configure
Load tmux-battery after you load catppuccin.
```sh
set -g @plugin 'catppuccin/tmux'
...
set -g @plugin 'tmux-plugins/tmux-battery'
```
Add the battery module to the status modules list.
```sh
set -g @catppuccin_status_modules" "... battery ..."
```
## Configuration Examples ## Configuration Examples
### Config 1 ### Config 1

23
status/battery.sh Normal file
View file

@ -0,0 +1,23 @@
show_battery() {
tmux set-option -g @batt_icon_charge_tier8 '󰁹'
tmux set-option -g @batt_icon_charge_tier7 '󰂁'
tmux set-option -g @batt_icon_charge_tier6 '󰁿'
tmux set-option -g @batt_icon_charge_tier5 '󰁾'
tmux set-option -g @batt_icon_charge_tier4 '󰁽'
tmux set-option -g @batt_icon_charge_tier3 '󰁼'
tmux set-option -g @batt_icon_charge_tier2 '󰁻'
tmux set-option -g @batt_icon_charge_tier1 '󰁺'
tmux set-option -g @batt_icon_status_charged '󰚥'
tmux set-option -g @batt_icon_status_charging '󰂄'
tmux set-option -g @batt_icon_status_discharging '󰂃'
tmux set-option -g @batt_icon_status_unknown '󰂑'
local index=$1
local icon="$(get_tmux_option "@catppuccin_battery_icon" "#{battery_icon}")"
local color="$(get_tmux_option "@catppuccin_battery_color" "$thm_yellow")"
local text="$(get_tmux_option "@catppuccin_battery_text" "#{battery_percentage}")"
local module=$( build_status_module "$index" "$icon" "$color" "$text" )
echo $module
}