Home

Awesome

Tmux battery status

Enables displaying battery percentage and status icon in tmux status-right.

Installation

In order to read the battery status, this plugin depends on having one of the following applications installed:

In a normal situation, one of the above should be installed on your system by default and thus it should not be necessary to specifically install one of them. That being said, the acpi utility is currently recommended for use over upower where possible due to ongoing CPU usage issues.

Installation with Tmux Plugin Manager (recommended)

Add plugin to the list of TPM plugins in .tmux.conf:

set -g @plugin 'tmux-plugins/tmux-battery'

Hit <prefix> + I to fetch the plugin and source it.

If format strings are added to status-right, they should now be visible.

Manual Installation

Clone the repo:

git clone https://github.com/tmux-plugins/tmux-battery ~/clone/path

Add this line to the bottom of .tmux.conf:

run-shell ~/clone/path/battery.tmux

From the terminal, reload TMUX environment:

tmux source-file ~/.tmux.conf

If format strings are added to status-right, they should now be visible.

Usage

Add any of the supported format strings (see below) to the status-right tmux option in .tmux.conf. Example:

set -g status-right '#{battery_status_bg} Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M '

Supported Format Strings

* These format strings can be further customized via options as described below.

Options

#{battery_remain}

Defaults

Options

Icons/Colors

By default, the following colors and icons are used. (The exact colors displayed depends on your terminal / X11 config.)

Please be aware that the 'level of charge' as noted below (e.g. [80%-95%)) uses interval notation. If you are unfamiliar with it, <a href="https://en.wikipedia.org/wiki/Bracket_(mathematics)#Intervals">check it out here</a>.

Also, a note about the @batt_color_... options: @batt_color_..._primary_... options are what will be displayed in the main bg or fg format strings you choose - e.g. if you use #{battery_color_bg}, the @batt_color_..._primary_... colors you choose will be the background. Likewise, the corresponding @batt_color_..._secondary_... color will be the foreground.

Level of Charge Colors:

Status Colors:

Level of Charge Icons:

Status Icons:

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:

set -g @batt_icon_charge_tier8 '🌕'
set -g @batt_icon_charge_tier7 '🌖'
set -g @batt_icon_charge_tier6 '🌖'
set -g @batt_icon_charge_tier5 '🌗'
set -g @batt_icon_charge_tier4 '🌗'
set -g @batt_icon_charge_tier3 '🌘'
set -g @batt_icon_charge_tier2 '🌘'
set -g @batt_icon_charge_tier1 '🌑'
set -g @batt_icon_status_charged '🔋'
set -g @batt_icon_status_charging '⚡'
set -g @batt_icon_status_discharging '👎'
set -g @batt_color_status_primary_charged '#3daee9'
set -g @batt_color_status_primary_charging '#3daee9'

Don't forget to reload the tmux environment after you do this by either hitting <prefix> + I if tmux battery is installed via the tmux plugin manager, or by typing tmux source-file ~/.tmux.conf in the terminal if tmux battery is manually installed.

Warning: The battery icon change most likely will not be instant. When you un-plug the power cord, it will take some time (15 - 60 seconds) for the icon to change. This depends on the status-interval tmux option. Setting it to 15 seconds should be good enough.

Examples

These are all examples of the default plugin color and icon schemes paired with the default tmux color scheme using the following status-right and status-right-length settings in .tmux.conf

set -g status-right 'Colors: #{battery_color_bg}bg#[default] #{battery_color_fg}fg#[default] #{battery_color_charge_bg}charge_bg#[default] #{battery_color_charge_fg}charge_fg#[default] #{battery_color_status_bg}status_bg#[default] #{battery_color_status_fg}status_fg#[default] | Graph: #{battery_graph} | Icon: #{battery_icon} | Charge Icon: #{battery_icon_charge} | Status Icon: #{battery_icon_status} | Percent: #{battery_percentage} | Remain: #{battery_remain}'
set -g status-right-length '150'

Battery charging at tier 8 [95%-100%]:<br> battery-charging-tier8

Battery charging at tier 7 [80%-95%):<br> battery-charging-tier7

Battery charging at tier 6 [65%-80%):<br> battery-charging-tier6

Battery charging at tier 5 [50%-65%):<br> battery-charging-tier5

Battery charging at tier 4 [35%-50%):<br> battery-charging-tier4

Battery charging at tier 3 [20%-35%):<br> battery-charging-tier3

Battery charging at tier 2 (5%-20%):<br> battery-charging-tier2

Battery charging at tier 1 [0%-5%]:<br> battery-charging-tier1

Battery discharging at tier 8 [95%-100%]:<br> battery-discharging-tier8

Battery discharging at tier 7 [80%-95%):<br> battery-discharging-tier7

Battery discharging at tier 6 [65%-80%):<br> battery-discharging-tier6

Battery discharging at tier 5 [50%-65%):<br> battery-discharging-tier5

Battery discharging at tier 4 [35%-50%):<br> battery-discharging-tier4

Battery discharging at tier 3 [20%-35%):<br> battery-discharging-tier3

Battery discharging at tier 2 (5%-20%):<br> battery-discharging-tier2

Battery discharging at tier 1 [0%-5%]:<br> battery-discharging-tier1

Battery in 'attached' status:<br> battery-status-attached

Battery in an unknown status:<br> battery-status-unknown

Tmux Plugins

This plugin is part of the tmux-plugins organisation. Checkout plugins as resurrect, logging, online status, and many more over at the tmux-plugins organisation page.

Maintainer

Contributors

License

MIT