New TMUX statusbar and config cleanup
This commit is contained in:
6
config-files/.config/tmux/plugins/theme/.shellcheckrc
Normal file
6
config-files/.config/tmux/plugins/theme/.shellcheckrc
Normal file
@@ -0,0 +1,6 @@
|
||||
shell=bash
|
||||
|
||||
# TODO: Find a way to declare color variables
|
||||
disable=SC2154
|
||||
|
||||
external-sources=true
|
||||
2
config-files/.config/tmux/plugins/theme/README.md
Normal file
2
config-files/.config/tmux/plugins/theme/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# Theme plugin
|
||||
Forked from the TMUX Catppuccin theme and adapted for Adwaita.
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
build_status_module() {
|
||||
local index="$1"
|
||||
local icon="$2"
|
||||
local color="$3"
|
||||
local text="$4"
|
||||
|
||||
if [ "$status_fill" = "icon" ]; then
|
||||
local bg
|
||||
local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
|
||||
local show_text="#[fg=$thm_fg,bg=$thm_gray] $text"
|
||||
|
||||
if [ "$status_connect_separator" = "yes" ]; then
|
||||
bg="$thm_gray"
|
||||
else
|
||||
bg="default"
|
||||
fi
|
||||
|
||||
local show_left_separator="#[fg=$color,bg=$bg,nobold,nounderscore,noitalics]$status_left_separator"
|
||||
local show_middle_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_middle_separator"
|
||||
local show_right_separator="#[fg=$thm_gray,bg=$bg,nobold,nounderscore,noitalics]$status_right_separator"
|
||||
fi
|
||||
|
||||
if [ "$status_fill" = "all" ]; then
|
||||
local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
|
||||
local show_text="#[fg=$thm_bg,bg=$color]$text"
|
||||
|
||||
if [ "$status_connect_separator" = "yes" ]; then
|
||||
local show_left_separator="#[fg=$color,nobold,nounderscore,noitalics]$status_left_separator"
|
||||
local show_right_separator="#[fg=$color,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
|
||||
|
||||
else
|
||||
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_left_separator"
|
||||
local show_right_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_right_separator"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ $((index)) -eq 0 ]; then
|
||||
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_left_separator"
|
||||
fi
|
||||
|
||||
if [ -z "$icon" ] ; then
|
||||
show_icon=""
|
||||
fi
|
||||
|
||||
echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator"
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
build_pane_format() {
|
||||
local number=$1
|
||||
local color=$2
|
||||
local background=$3
|
||||
local text=$4
|
||||
local fill=$5
|
||||
|
||||
if [ "$pane_status_enable" = "yes" ]
|
||||
then
|
||||
if [ "$fill" = "none" ]
|
||||
then
|
||||
local show_left_separator="#[fg=$thm_gray,bg=default,nobold,nounderscore,noitalics]$pane_left_separator"
|
||||
local show_number="#[fg=$thm_fg,bg=$thm_gray]$number"
|
||||
local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$pane_middle_separator"
|
||||
local show_text="#[fg=$thm_fg,bg=$thm_gray]$text"
|
||||
local show_right_separator="#[fg=$thm_gray,bg=default]$pane_right_separator"
|
||||
fi
|
||||
|
||||
if [ "$fill" = "all" ]
|
||||
then
|
||||
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$pane_left_separator"
|
||||
local show_number="#[fg=$background,bg=$color]$number"
|
||||
local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$pane_middle_separator"
|
||||
local show_text="#[fg=$background,bg=$color]$text"
|
||||
local show_right_separator="#[fg=$color,bg=default]$pane_right_separator"
|
||||
fi
|
||||
|
||||
if [ "$fill" = "number" ]
|
||||
then
|
||||
local show_number="#[fg=$background,bg=$color]$number"
|
||||
local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$pane_middle_separator"
|
||||
local show_text="#[fg=$thm_fg,bg=$background]$text"
|
||||
|
||||
if [ "$pane_number_position" = "right" ]
|
||||
then
|
||||
local show_left_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$pane_left_separator"
|
||||
local show_right_separator="#[fg=$color,bg=default]$pane_right_separator"
|
||||
fi
|
||||
|
||||
if [ "$pane_number_position" = "left" ]
|
||||
then
|
||||
local show_right_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$pane_right_separator"
|
||||
local show_left_separator="#[fg=$color,bg=default]$pane_left_separator"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
local final_pane_format
|
||||
|
||||
if [ "$pane_number_position" = "right" ]
|
||||
then
|
||||
final_pane_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator"
|
||||
fi
|
||||
|
||||
if [ "$pane_number_position" = "left" ]
|
||||
then
|
||||
final_pane_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator"
|
||||
fi
|
||||
|
||||
echo "$final_pane_format"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
show_window_status=
|
||||
|
||||
build_window_format() {
|
||||
local number="$1"
|
||||
local color="$2"
|
||||
local background="$3"
|
||||
local text="$4"
|
||||
local fill="$5"
|
||||
local window_type="$6"
|
||||
|
||||
# NOTE: For backwards compatibility remove before 1.0.0 and update default for
|
||||
# `@catppuccin_window_status`
|
||||
if [ "$window_status" = "no" ]; then
|
||||
window_status_enable="$(get_tmux_option "@catppuccin_window_status_enable" "")"
|
||||
|
||||
if [ -n "$window_status_enable" ]; then
|
||||
tmux_echo "catppuccin warning: \\\"@catppuccin_window_status_enable\\\" and \\\"@catppuccin_window_status_icon_enable\\\" has been replaced by\n\t \
|
||||
\\\"@catppuccin_window_status\\\" with the options \\\"no\\\", \\\"icon\\\" and \\\"text\\\"" 104
|
||||
|
||||
if [ "$window_status_enable" = "yes" ]; then
|
||||
window_status_icon_enable="$(get_tmux_option "@catppuccin_window_status_icon_enable" "yes")"
|
||||
if [ "$window_status_icon_enable" = "yes" ]; then
|
||||
window_status="icon"
|
||||
else
|
||||
window_status="text"
|
||||
fi
|
||||
else
|
||||
window_status="no"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! "$window_status" = "no" ]; then
|
||||
local icon
|
||||
icon="$(build_window_icon)"
|
||||
text="$text$icon"
|
||||
fi
|
||||
|
||||
if [ "$window_type" = "current" ]; then
|
||||
add_tmux_batch_option "@catppuccin_window_current_left_separator"
|
||||
add_tmux_batch_option "@catppuccin_window_current_middle_separator"
|
||||
add_tmux_batch_option "@catppuccin_window_current_right_separator"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
window_left_separator=$(get_tmux_batch_option "@catppuccin_window_current_left_separator" "$window_left_separator")
|
||||
window_middle_separator=$(get_tmux_batch_option "@catppuccin_window_current_middle_separator" "$window_middle_separator")
|
||||
window_right_separator=$(get_tmux_batch_option "@catppuccin_window_current_right_separator" "$window_right_separator")
|
||||
fi
|
||||
|
||||
if [ "$fill" = "none" ]; then
|
||||
local show_number="#[fg=$thm_fg,bg=$thm_gray]$number"
|
||||
local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator"
|
||||
local show_text="#[fg=$thm_fg,bg=$thm_gray]$text"
|
||||
|
||||
if [ "$status_connect_separator" = "yes" ]; then
|
||||
local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
|
||||
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator"
|
||||
|
||||
else
|
||||
local show_left_separator="#[fg=$thm_gray,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
|
||||
local show_right_separator="#[fg=$thm_gray,bg=default]$window_right_separator"
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ "$fill" = "all" ]; then
|
||||
local show_number="#[fg=$background,bg=$color]$number"
|
||||
local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$window_middle_separator"
|
||||
local show_text="#[fg=$background,bg=$color]$text"
|
||||
|
||||
if [ "$status_connect_separator" = "yes" ]; then
|
||||
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
|
||||
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"
|
||||
|
||||
else
|
||||
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
|
||||
local show_right_separator="#[fg=$color,bg=default]$window_right_separator"
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ "$fill" = "number" ]; then
|
||||
local show_number="#[fg=$background,bg=$color]$number"
|
||||
local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$window_middle_separator"
|
||||
local show_text="#[fg=$thm_fg,bg=$background]$text"
|
||||
|
||||
if [ "$window_number_position" = "right" ]; then
|
||||
if [ "$status_connect_separator" = "yes" ]; then
|
||||
local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
|
||||
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"
|
||||
|
||||
else
|
||||
local show_left_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
|
||||
local show_right_separator="#[fg=$color,bg=default]$window_right_separator"
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$window_number_position" = "left" ]; then
|
||||
if [ "$status_connect_separator" = "yes" ]; then
|
||||
local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator"
|
||||
local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator"
|
||||
|
||||
else
|
||||
local show_right_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$window_right_separator"
|
||||
local show_left_separator="#[fg=$color,bg=default]$window_left_separator"
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
local final_window_format
|
||||
|
||||
if [ "$window_number_position" = "right" ]; then
|
||||
final_window_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator"
|
||||
fi
|
||||
|
||||
if [ "$window_number_position" = "left" ]; then
|
||||
final_window_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator"
|
||||
fi
|
||||
|
||||
echo "$final_window_format"
|
||||
}
|
||||
|
||||
prepend_separator() {
|
||||
local field="$1"
|
||||
|
||||
echo "${field:+ $field}"
|
||||
}
|
||||
|
||||
build_window_icon() {
|
||||
# Only update `show_window_status` if it's not empty
|
||||
# this module is ran twice once for current and once for default
|
||||
# meaning 2 calls to build_window_icon wich will/should both return the same
|
||||
# result.
|
||||
if [ -z "$show_window_status" ]; then
|
||||
local custom_icon_window_last \
|
||||
custom_icon_window_zoom custom_icon_window_mark custom_icon_window_mark \
|
||||
custom_icon_window_silent custom_icon_window_activity custom_icon_window_bell
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options_commands=()
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options=()
|
||||
|
||||
add_tmux_batch_option "@catppuccin_icon_window_last"
|
||||
add_tmux_batch_option "@catppuccin_icon_window_current"
|
||||
add_tmux_batch_option "@catppuccin_icon_window_zoom"
|
||||
add_tmux_batch_option "@catppuccin_icon_window_mark"
|
||||
add_tmux_batch_option "@catppuccin_icon_window_silent"
|
||||
add_tmux_batch_option "@catppuccin_icon_window_activity"
|
||||
add_tmux_batch_option "@catppuccin_icon_window_bell"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
custom_icon_window_last=$(get_tmux_batch_option "@catppuccin_icon_window_last" "")
|
||||
custom_icon_window_current=$(get_tmux_batch_option "@catppuccin_icon_window_current" "")
|
||||
custom_icon_window_zoom=$(get_tmux_batch_option "@catppuccin_icon_window_zoom" "")
|
||||
custom_icon_window_mark=$(get_tmux_batch_option "@catppuccin_icon_window_mark" "")
|
||||
custom_icon_window_silent=$(get_tmux_batch_option "@catppuccin_icon_window_silent" "")
|
||||
custom_icon_window_activity=$(get_tmux_batch_option "@catppuccin_icon_window_activity" "")
|
||||
custom_icon_window_bell=$(get_tmux_batch_option "@catppuccin_icon_window_bell" "")
|
||||
|
||||
if [ "$window_status" = "icon" ]; then
|
||||
# icon order: #!~[*-]MZ
|
||||
show_window_status=""
|
||||
show_window_status+="#{?window_activity_flag,$(prepend_separator "${custom_icon_window_activity}"),}"
|
||||
show_window_status+="#{?window_bell_flag,$(prepend_separator "${custom_icon_window_bell}"),}"
|
||||
show_window_status+="#{?window_silence_flag,$(prepend_separator "${custom_icon_window_silent}"),}"
|
||||
show_window_status+="#{?window_active,$(prepend_separator "${custom_icon_window_current}"),}"
|
||||
show_window_status+="#{?window_last_flag,$(prepend_separator "${custom_icon_window_last}"),}"
|
||||
show_window_status+="#{?window_marked_flag,$(prepend_separator "${custom_icon_window_mark}"),}"
|
||||
show_window_status+="#{?window_zoomed_flag,$(prepend_separator "${custom_icon_window_zoom}"),}"
|
||||
elif [ "$window_status" = "text" ]; then
|
||||
show_window_status=" #F"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$show_window_status"
|
||||
}
|
||||
72
config-files/.config/tmux/plugins/theme/custom/README.md
Normal file
72
config-files/.config/tmux/plugins/theme/custom/README.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# User Defined Modules
|
||||
|
||||
This folder is used to store user defined modules. You can use this folder to
|
||||
add a new module or override any existing module. To override an existing
|
||||
module, make sure that you use the same name for your module as the module you
|
||||
want to override. You can also override the window module for the current and
|
||||
default window.
|
||||
|
||||
## Creating A New Module
|
||||
|
||||
> [!NOTE]
|
||||
> Changes will only be applied after reloading your Tmux configuration by executing `tmux source-file ~/.tmux.conf`.
|
||||
|
||||
You can create a custom module by following the steps outlined below. This can be something you create entirely by yourself or integrating an existing Tmux plugin.
|
||||
|
||||
1. Create a new file in `~/.tmux/plugins/tmux/custom/<module_name>.sh` to store the custom module.
|
||||
- The file **must** end in `.sh`
|
||||
- The file **does not** need to be set as executable.
|
||||
|
||||
2. Copy the following template to this new file. Make sure to replace every instance of `<module_name>` by the name you chose as filename.
|
||||
|
||||
```bash
|
||||
# If this module depends on an external Tmux plugin, say so in a comment.
|
||||
# E.g.: Requires https://github.com/aaronpowell/tmux-weather
|
||||
|
||||
show_<module_name>() { # This function name must match the module name!
|
||||
local index icon color text module
|
||||
|
||||
index=$1 # This variable is used internally by the module loader in order to know the position of this module
|
||||
|
||||
icon="$( get_tmux_option "@catppuccin_<module_name>_icon" "" )"
|
||||
color="$( get_tmux_option "@catppuccin_<module_name>_color" "$thm_orange" )"
|
||||
text="$( get_tmux_option "@catppuccin_<module_name>_text" "hello world" )"
|
||||
|
||||
module=$( build_status_module "$index" "$icon" "$color" "$text" )
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
```
|
||||
|
||||
3. Add the custom module to the list of modules in `.tmux.conf`
|
||||
|
||||
```bash
|
||||
set -g @catppuccin_status_modules_right "... <module_name> ..."
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
Change the icon to one from [Nerd Fonts](https://www.nerdfonts.com/cheat-sheet).
|
||||
|
||||
Change the color to one of the [official colors](../catppuccin-macchiato.tmuxtheme), for instance `"$thm_cyan"`, or to a hexadecimal color like `"#00ff00"`.
|
||||
|
||||
The text to display can either be:
|
||||
|
||||
- A static text, e.g. `"hello world"`.
|
||||
- The output of a command, e.g. `"#( date +%T )"`.
|
||||
- The output of a script, e.g. `"#( $HOME/my_script.sh )"` . Any script will do, e.g. a Bash or Python script that prints some text, but ensure that it is executable: `chmod u+x my_script.sh`.
|
||||
- An existing Tmux plugin, e.g. `" #{forecast} "` for the [Tmux Weather plugin](https://github.com/aaronpowell/tmux-weather).
|
||||
|
||||
Note that the icon and the color can be generated dynamically as well, for instance by having a Bash script `echo` a hexadecimal color.
|
||||
|
||||
To modify how often the modules are updated, add the following to `.tmux.conf`:
|
||||
|
||||
```tmux
|
||||
set -g status-interval <number of seconds>
|
||||
```
|
||||
|
||||
To configure a custom path for your modules, set this option:
|
||||
|
||||
```tmux
|
||||
set -g @catppuccin_custom_plugin_dir "<path>"
|
||||
```
|
||||
16
config-files/.config/tmux/plugins/theme/custom/example.sh
Normal file
16
config-files/.config/tmux/plugins/theme/custom/example.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
# If this module depends on an external Tmux plugin, say so in a comment.
|
||||
# E.g.: Requires https://github.com/aaronpowell/tmux-weather
|
||||
|
||||
show_test() { # This function name must match the module name!
|
||||
local index icon color text module
|
||||
|
||||
index=$1 # This variable is used internally by the module loader in order to know the position of this module
|
||||
icon="$( get_tmux_option "@catppuccin_test_icon" "" )"
|
||||
color="$( get_tmux_option "@catppuccin_test_color" "$thm_orange" )"
|
||||
text="$( get_tmux_option "@catppuccin_test_text" "hello world" )"
|
||||
|
||||
module=$( build_status_module "$index" "$icon" "$color" "$text" )
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
show_pane_default_format() {
|
||||
local number color background text fill
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options_commands=()
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options=()
|
||||
|
||||
add_tmux_batch_option "@catppuccin_pane_color"
|
||||
add_tmux_batch_option "@catppuccin_pane_background_color"
|
||||
add_tmux_batch_option "@catppuccin_pane_default_text"
|
||||
add_tmux_batch_option "@catppuccin_pane_default_fill"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
number="#{pane_index}"
|
||||
color="$(get_tmux_batch_option "@catppuccin_pane_color" "$thm_green")"
|
||||
background="$(get_tmux_batch_option "@catppuccin_pane_background_color" "$thm_gray")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_pane_default_text" "#{b:pane_current_path}")"
|
||||
fill="$(get_tmux_batch_option "@catppuccin_pane_default_fill" "number")" # number, all, none
|
||||
|
||||
default_pane_format=$(build_pane_format "$number" "$color" "$background" "$text" "$fill")
|
||||
|
||||
echo "$default_pane_format"
|
||||
}
|
||||
6
config-files/.config/tmux/plugins/theme/renovate.json
Normal file
6
config-files/.config/tmux/plugins/theme/renovate.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"local>catppuccin/renovate-config"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
show_application() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "application"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_application_icon" "")
|
||||
color=$(get_tmux_batch_option "@catppuccin_application_color" "$thm_pink")
|
||||
text=$(get_tmux_batch_option "@catppuccin_application_text" "#{pane_current_command}")
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
30
config-files/.config/tmux/plugins/theme/status/battery.sh
Normal file
30
config-files/.config/tmux/plugins/theme/status/battery.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
show_battery() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "battery"
|
||||
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier8 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier7 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier6 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier5 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier4 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier3 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier2 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier1 ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_charged ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_charging ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_discharging ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_unknown ;")
|
||||
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_attached ;")
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_battery_icon" "#{battery_icon}")
|
||||
color=$(get_tmux_batch_option "@catppuccin_battery_color" "$thm_yellow")
|
||||
text=$(get_tmux_batch_option "@catppuccin_battery_text" "#{battery_percentage}")
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
16
config-files/.config/tmux/plugins/theme/status/clima.sh
Normal file
16
config-files/.config/tmux/plugins/theme/status/clima.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
# Requires https://github.com/vascomfnunes/tmux-clima
|
||||
show_clima() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "clima"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon="$(get_tmux_batch_option "@catppuccin_clima_icon" "")"
|
||||
color="$(get_tmux_batch_option "@catppuccin_clima_color" "$thm_yellow")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_clima_text" "#{clima}")"
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
20
config-files/.config/tmux/plugins/theme/status/cpu.sh
Normal file
20
config-files/.config/tmux/plugins/theme/status/cpu.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
show_cpu() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "cpu"
|
||||
|
||||
tmux_batch_options_commands+=("set-option -gq @cpu_low_bg_color $thm_yellow ;") # background color when cpu is low
|
||||
tmux_batch_options_commands+=("set-option -gq @cpu_medium_bg_color $thm_orange ;") # background color when cpu is medium
|
||||
tmux_batch_options_commands+=("set-option -gq @cpu_high_bg_color $thm_red ;") # background color when cpu is high
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_cpu_icon" "")
|
||||
color="$(get_tmux_batch_option "@catppuccin_cpu_color" "#{cpu_bg_color}")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_cpu_text" "#{cpu_percentage}")"
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
15
config-files/.config/tmux/plugins/theme/status/date_time.sh
Normal file
15
config-files/.config/tmux/plugins/theme/status/date_time.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
show_date_time() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "date_time"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon="$(get_tmux_batch_option "@catppuccin_date_time_icon" "")"
|
||||
color="$(get_tmux_batch_option "@catppuccin_date_time_color" "$thm_blue")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_date_time_text" "%Y-%m-%d %H:%M")"
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
15
config-files/.config/tmux/plugins/theme/status/directory.sh
Normal file
15
config-files/.config/tmux/plugins/theme/status/directory.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
show_directory() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "directory"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_directory_icon" "")
|
||||
color=$(get_tmux_batch_option "@catppuccin_directory_color" "$thm_pink")
|
||||
text=$(get_tmux_batch_option "@catppuccin_directory_text" "#{b:pane_current_path}")
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
17
config-files/.config/tmux/plugins/theme/status/gitmux.sh
Normal file
17
config-files/.config/tmux/plugins/theme/status/gitmux.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
# Requires https://github.com/arl/gitmux
|
||||
|
||||
show_gitmux() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "gitmux"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon="$(get_tmux_batch_option "@catppuccin_gitmux_icon" "")"
|
||||
color="$(get_tmux_batch_option "@catppuccin_gitmux_color" "$thm_green")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_gitmux_text" "#(gitmux \"#{pane_current_path}\")")"
|
||||
|
||||
module=$( build_status_module "$index" "$icon" "$color" "$text" )
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
15
config-files/.config/tmux/plugins/theme/status/host.sh
Normal file
15
config-files/.config/tmux/plugins/theme/status/host.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
show_host() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "host"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_host_icon" "")
|
||||
color=$(get_tmux_batch_option "@catppuccin_host_color" "$thm_magenta")
|
||||
text=$(get_tmux_batch_option "@catppuccin_host_text" "#H")
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
24
config-files/.config/tmux/plugins/theme/status/kube.sh
Normal file
24
config-files/.config/tmux/plugins/theme/status/kube.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
# Requires https://github.com/jonmosco/kube-tmux
|
||||
|
||||
show_kube() {
|
||||
local index icon color text context_color namespace_color symbol_enabled module
|
||||
|
||||
tmux_batch_setup_status_module "kube"
|
||||
|
||||
add_tmux_batch_option "@catppuccin_kube_context_color"
|
||||
add_tmux_batch_option "@catppuccin_kube_namespace_color"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_kube_icon" "")
|
||||
color=$(get_tmux_batch_option "@catppuccin_kube_color" "$thm_blue")
|
||||
context_color=$(get_tmux_batch_option "@catppuccin_kube_context_color" "#{thm_red}")
|
||||
namespace_color=$(get_tmux_batch_option "@catppuccin_kube_namespace_color" "#{thm_cyan}")
|
||||
symbol_enabled=${KUBE_TMUX_SYMBOL_ENABLE:-false}
|
||||
text=$(get_tmux_batch_option "@catppuccin_kube_text" "#(KUBE_TMUX_SYMBOL_ENABLE=$symbol_enabled \${TMUX_PLUGIN_MANAGER_PATH}kube-tmux/kube.tmux 250 '$context_color' '$namespace_color')")
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
15
config-files/.config/tmux/plugins/theme/status/load.sh
Normal file
15
config-files/.config/tmux/plugins/theme/status/load.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
show_load() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "load"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon="$(get_tmux_batch_option "@catppuccin_load_icon" "")"
|
||||
color="$(get_tmux_batch_option "@catppuccin_load_color" "$thm_blue")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_load_text" "#{load_full}")"
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# Requires https://github.com/olimorris/tmux-pomodoro-plus
|
||||
|
||||
show_pomodoro_plus() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "pomodoro_plus"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon="$( get_tmux_batch_option "@catppuccin_pomodoro_plus_icon" "" )"
|
||||
color="$( get_tmux_batch_option "@catppuccin_pomodoro_plus_color" "$thm_orange" )"
|
||||
text="$( get_tmux_batch_option "@catppuccin_pomodoro_plus_text" "#{pomodoro_status}" )"
|
||||
|
||||
module=$( build_status_module "$index" "$icon" "$color" "$text" )
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
15
config-files/.config/tmux/plugins/theme/status/session.sh
Normal file
15
config-files/.config/tmux/plugins/theme/status/session.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
show_session() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "session"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_session_icon" "")
|
||||
color=$(get_tmux_batch_option "@catppuccin_session_color" "#{?client_prefix,$thm_red,$thm_green}")
|
||||
text=$(get_tmux_batch_option "@catppuccin_session_text" "#S")
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
15
config-files/.config/tmux/plugins/theme/status/uptime.sh
Normal file
15
config-files/.config/tmux/plugins/theme/status/uptime.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
show_uptime() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "uptime"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon="$(get_tmux_batch_option "@catppuccin_uptime_icon" "")"
|
||||
color="$(get_tmux_batch_option "@catppuccin_uptime_color" "$thm_green")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_uptime_text" "#(uptime | sed 's/^[^,]*up *//; s/, *[[:digit:]]* user.*//; s/ day.*, */d /; s/:/h /; s/ min//; s/$/m/')")"
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
15
config-files/.config/tmux/plugins/theme/status/user.sh
Normal file
15
config-files/.config/tmux/plugins/theme/status/user.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
show_user() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "user"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon=$(get_tmux_batch_option "@catppuccin_user_icon" "")
|
||||
color=$(get_tmux_batch_option "@catppuccin_user_color" "$thm_cyan")
|
||||
text=$(get_tmux_batch_option "@catppuccin_user_text" "#(whoami)")
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
17
config-files/.config/tmux/plugins/theme/status/weather.sh
Normal file
17
config-files/.config/tmux/plugins/theme/status/weather.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
# Requires https://github.com/xamut/tmux-weather.
|
||||
|
||||
show_weather() {
|
||||
local index icon color text module
|
||||
|
||||
tmux_batch_setup_status_module "weather"
|
||||
run_tmux_batch_commands
|
||||
|
||||
index=$1
|
||||
icon="$(get_tmux_batch_option "@catppuccin_weather_icon" "")"
|
||||
color="$(get_tmux_batch_option "@catppuccin_weather_color" "$thm_yellow")"
|
||||
text="$(get_tmux_batch_option "@catppuccin_weather_text" "#{weather}")"
|
||||
|
||||
module=$(build_status_module "$index" "$icon" "$color" "$text")
|
||||
|
||||
echo "$module"
|
||||
}
|
||||
223
config-files/.config/tmux/plugins/theme/theme.tmux
Executable file
223
config-files/.config/tmux/plugins/theme/theme.tmux
Executable file
@@ -0,0 +1,223 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Set path of script
|
||||
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# import
|
||||
# shellcheck source=./builder/module_builder.sh
|
||||
source "${PLUGIN_DIR}/builder/module_builder.sh"
|
||||
# shellcheck source=./builder/window_builder.sh
|
||||
source "${PLUGIN_DIR}/builder/window_builder.sh"
|
||||
# shellcheck source=./builder/pane_builder.sh
|
||||
source "${PLUGIN_DIR}/builder/pane_builder.sh"
|
||||
# shellcheck source=./utils/tmux_utils.sh
|
||||
source "${PLUGIN_DIR}/utils/tmux_utils.sh"
|
||||
# shellcheck source=./utils/interpolate_utils.sh
|
||||
source "${PLUGIN_DIR}/utils/interpolate_utils.sh"
|
||||
# shellcheck source=./utils/module_utils.sh
|
||||
source "${PLUGIN_DIR}/utils/module_utils.sh"
|
||||
|
||||
main() {
|
||||
# Aggregate all commands in one array
|
||||
local tmux_commands=()
|
||||
|
||||
# Aggregate all tmux option for tmux_batch_option
|
||||
local tmux_batch_options_commands=()
|
||||
local tmux_batch_options=()
|
||||
|
||||
# Batch options for loading the colorscheme and everyting before
|
||||
add_tmux_batch_option "@catppuccin_custom_plugin_dir"
|
||||
add_tmux_batch_option "@catppuccin_flavor"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
# module directories
|
||||
local custom_path modules_custom_path modules_status_path modules_window_path modules_pane_path
|
||||
custom_path="$(get_tmux_batch_option "@catppuccin_custom_plugin_dir" "${PLUGIN_DIR}/custom")"
|
||||
modules_custom_path=$custom_path
|
||||
modules_status_path=$PLUGIN_DIR/status
|
||||
modules_window_path=$PLUGIN_DIR/window
|
||||
modules_pane_path=$PLUGIN_DIR/pane
|
||||
|
||||
# load local theme
|
||||
local theme
|
||||
local color_interpolation=()
|
||||
local color_values=()
|
||||
local temp
|
||||
|
||||
theme="$(get_tmux_batch_option "@catppuccin_flavor" "")"
|
||||
|
||||
# NOTE: For backwards compatibility remove before 1.0.0 and set default for
|
||||
# `@catppuccin_flavor` from `""` to `"mocha"`
|
||||
if [ -z "$theme" ]; then
|
||||
theme="$(get_tmux_option "@catppuccin_flavour" "")"
|
||||
if [ -n "$theme" ]; then
|
||||
tmux_echo "catppuccin warning: \\\"@catppuccin_flavour\\\" has been deprecated use \\\"@catppuccin_flavor\\\"" 103
|
||||
else
|
||||
theme="mocha"
|
||||
fi
|
||||
fi
|
||||
|
||||
# NOTE: Pulling in the selected theme by the theme that's being set as local
|
||||
# variables.
|
||||
# https://github.com/dylanaraps/pure-sh-bible#parsing-a-keyval-file
|
||||
# shellcheck source=./catppuccin-frappe.tmuxtheme
|
||||
while IFS='=' read -r key val; do
|
||||
# Skip over lines containing comments.
|
||||
# (Lines starting with '#').
|
||||
[ "${key##\#*}" ] || continue
|
||||
|
||||
# '$key' stores the key.
|
||||
# '$val' stores the value.
|
||||
eval "local $key"="$val"
|
||||
|
||||
# TODO: Find a better way to strip the quotes from `$val`
|
||||
temp="${val%\"}"
|
||||
temp="${temp#\"}"
|
||||
color_interpolation+=("\#{$key}")
|
||||
color_values+=("${temp}")
|
||||
done <"${PLUGIN_DIR}/themes/catppuccin_${theme}.tmuxtheme"
|
||||
|
||||
# Batch options for `./catppuccin.tmux`
|
||||
add_tmux_batch_option "@catppuccin_status_default"
|
||||
add_tmux_batch_option "@catppuccin_status_justify"
|
||||
add_tmux_batch_option "@catppuccin_status_background"
|
||||
add_tmux_batch_option "@catppuccin_menu_style"
|
||||
add_tmux_batch_option "@catppuccin_menu_selected_style"
|
||||
add_tmux_batch_option "@catppuccin_menu_border_style"
|
||||
add_tmux_batch_option "@catppuccin_pane_status_enabled"
|
||||
add_tmux_batch_option "@catppuccin_pane_border_status"
|
||||
add_tmux_batch_option "@catppuccin_pane_border_style"
|
||||
add_tmux_batch_option "@catppuccin_pane_active_border_style"
|
||||
add_tmux_batch_option "@catppuccin_pane_left_separator"
|
||||
add_tmux_batch_option "@catppuccin_pane_middle_separator"
|
||||
add_tmux_batch_option "@catppuccin_pane_right_separator"
|
||||
add_tmux_batch_option "@catppuccin_pane_number_position"
|
||||
add_tmux_batch_option "@catppuccin_window_separator"
|
||||
add_tmux_batch_option "@catppuccin_window_left_separator"
|
||||
add_tmux_batch_option "@catppuccin_window_right_separator"
|
||||
add_tmux_batch_option "@catppuccin_window_middle_separator"
|
||||
add_tmux_batch_option "@catppuccin_window_number_position"
|
||||
add_tmux_batch_option "@catppuccin_window_status"
|
||||
add_tmux_batch_option "@catppuccin_status_left_separator"
|
||||
add_tmux_batch_option "@catppuccin_status_middle_separator"
|
||||
add_tmux_batch_option "@catppuccin_status_right_separator"
|
||||
add_tmux_batch_option "@catppuccin_status_connect_separator"
|
||||
add_tmux_batch_option "@catppuccin_status_fill"
|
||||
add_tmux_batch_option "@catppuccin_status_modules_left"
|
||||
add_tmux_batch_option "@catppuccin_status_modules_right"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
# status general
|
||||
local status_default status_justify status_background message_background
|
||||
status_default=$(get_tmux_batch_option "@catppuccin_status_default" "on")
|
||||
# shellcheck disable=SC2121
|
||||
set status "$status_default"
|
||||
|
||||
status_justify=$(get_tmux_batch_option "@catppuccin_status_justify" "left")
|
||||
set status-justify "$status_justify"
|
||||
|
||||
status_background=$(get_tmux_batch_option "@catppuccin_status_background" "theme")
|
||||
if [ "${status_background}" = "theme" ]; then
|
||||
set status-bg "${thm_bg}"
|
||||
message_background="${thm_gray}"
|
||||
else
|
||||
if [ "${status_background}" = "default" ]; then
|
||||
set status-style bg=default
|
||||
message_background="default"
|
||||
else
|
||||
message_background="$(do_color_interpolation "$status_background")"
|
||||
set status-bg "${message_background}"
|
||||
fi
|
||||
fi
|
||||
|
||||
set status-left-length "100"
|
||||
set status-right-length "100"
|
||||
|
||||
# messages
|
||||
set message-style "fg=${thm_cyan},bg=${message_background},align=centre"
|
||||
set message-command-style "fg=${thm_cyan},bg=${message_background},align=centre"
|
||||
|
||||
# menu
|
||||
local menu_style menu_selected_style menu_border_style
|
||||
menu_style=$(get_interpolated_tmux_batch_option "@catppuccin_menu_style" "default")
|
||||
menu_selected_style=$(get_interpolated_tmux_batch_option "@catppuccin_menu_selected_style" "fg=${thm_gray},bg=${thm_yellow}")
|
||||
menu_border_style=$(get_interpolated_tmux_batch_option "@catppuccin_menu_border_style" "default")
|
||||
set menu-style "$menu_style"
|
||||
set menu-selected-style "$menu_selected_style"
|
||||
set menu-border-style "$menu_border_style"
|
||||
|
||||
# panes
|
||||
local pane_border_status pane_border_style \
|
||||
pane_active_border_style pane_left_separator pane_middle_separator \
|
||||
pane_right_separator pane_number_position pane_format
|
||||
pane_status_enable=$(get_tmux_batch_option "@catppuccin_pane_status_enabled" "no") # yes
|
||||
pane_border_status=$(get_tmux_batch_option "@catppuccin_pane_border_status" "off") # bottom
|
||||
pane_border_style=$(
|
||||
get_interpolated_tmux_batch_option "@catppuccin_pane_border_style" "fg=${thm_gray}"
|
||||
)
|
||||
pane_active_border_style=$(
|
||||
get_interpolated_tmux_batch_option "@catppuccin_pane_active_border_style" \
|
||||
"#{?pane_in_mode,fg=${thm_yellow},#{?pane_synchronized,fg=${thm_magenta},fg=${thm_orange}}}"
|
||||
)
|
||||
pane_left_separator=$(get_tmux_batch_option "@catppuccin_pane_left_separator" "█")
|
||||
pane_middle_separator=$(get_tmux_batch_option "@catppuccin_pane_middle_separator" "█")
|
||||
pane_right_separator=$(get_tmux_batch_option "@catppuccin_pane_right_separator" "█")
|
||||
pane_number_position=$(get_tmux_batch_option "@catppuccin_pane_number_position" "left") # right, left
|
||||
pane_format=$(load_modules "pane_default_format" "$modules_custom_path" "$modules_pane_path")
|
||||
|
||||
setw pane-border-status "$pane_border_status"
|
||||
setw pane-active-border-style "$pane_active_border_style"
|
||||
setw pane-border-style "$pane_border_style"
|
||||
setw pane-border-format "$(do_color_interpolation "$pane_format")"
|
||||
|
||||
# window
|
||||
local window_status_separator window_left_separator window_right_separator \
|
||||
window_middle_separator window_number_position window_status_enable \
|
||||
window_format window_current_format
|
||||
|
||||
window_status_separator=$(get_interpolated_tmux_batch_option "@catppuccin_window_separator" "")
|
||||
setw window-status-separator "$window_status_separator"
|
||||
|
||||
window_left_separator=$(get_tmux_batch_option "@catppuccin_window_left_separator" "█")
|
||||
window_right_separator=$(get_tmux_batch_option "@catppuccin_window_right_separator" "█")
|
||||
window_middle_separator=$(get_tmux_batch_option "@catppuccin_window_middle_separator" "█ ")
|
||||
window_number_position=$(get_tmux_batch_option "@catppuccin_window_number_position" "left") # right, left
|
||||
|
||||
# NOTE: update default to `"no"` when removing the backwards compatibility for
|
||||
# `@catppuccin_window_status_enable` and
|
||||
# `@catppuccin_window_status_icon_enable` in ./builder/window_builder.sh
|
||||
window_status=$(get_tmux_batch_option "@catppuccin_window_status" "no") # no, icon, text
|
||||
|
||||
window_format=$(load_modules "window_default_format" "$modules_custom_path" "$modules_window_path")
|
||||
setw window-status-format "$(do_color_interpolation "$window_format")"
|
||||
|
||||
window_current_format=$(load_modules "window_current_format" "$modules_custom_path" "$modules_window_path")
|
||||
setw window-status-current-format "$(do_color_interpolation "$window_current_format")"
|
||||
|
||||
# status module
|
||||
local status_left_separator status_middle_separator status_right_separator status_connect_separator \
|
||||
status_fill status_modules_left status_modules_right
|
||||
status_left_separator=$(get_tmux_batch_option "@catppuccin_status_left_separator" "")
|
||||
status_right_separator=$(get_tmux_batch_option "@catppuccin_status_right_separator" "█")
|
||||
status_middle_separator=$(get_tmux_batch_option "@catppuccin_status_middle_separator" "")
|
||||
status_connect_separator=$(get_tmux_batch_option "@catppuccin_status_connect_separator" "yes")
|
||||
status_fill=$(get_tmux_batch_option "@catppuccin_status_fill" "icon")
|
||||
|
||||
status_modules_left=$(get_tmux_batch_option "@catppuccin_status_modules_left" "")
|
||||
loaded_modules_left=$(load_modules "$status_modules_left" "$modules_custom_path" "$modules_status_path")
|
||||
set status-left "$(do_color_interpolation "$loaded_modules_left")"
|
||||
|
||||
status_modules_right=$(get_tmux_batch_option "@catppuccin_status_modules_right" "application session")
|
||||
loaded_modules_right=$(load_modules "$status_modules_right" "$modules_custom_path" "$modules_status_path")
|
||||
set status-right "$(do_color_interpolation "$loaded_modules_right")"
|
||||
|
||||
# modes
|
||||
setw clock-mode-colour "${thm_blue}"
|
||||
setw mode-style "fg=${thm_pink} bg=${thm_black4} bold"
|
||||
|
||||
tmux "${tmux_commands[@]}"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -0,0 +1,17 @@
|
||||
# NOTE: you can use vars with $<var> and ${<var>} as long as the str is double quoted: ""
|
||||
# WARNING: hex colors can't contain capital letters
|
||||
|
||||
# --> Adwaita
|
||||
thm_bg="#1f1f1f"
|
||||
thm_fg="#ffffff"
|
||||
thm_cyan="#2aa1b3"
|
||||
thm_black="#242424"
|
||||
thm_gray="#303030"
|
||||
thm_magenta="#a347ba"
|
||||
thm_pink="#a347ba"
|
||||
thm_red="#c01c28"
|
||||
thm_green="#26a269"
|
||||
thm_yellow="#a2734c"
|
||||
thm_blue="#2a7bde"
|
||||
thm_orange="#a2734c"
|
||||
thm_black4="#1f1f1f"
|
||||
25
config-files/.config/tmux/plugins/theme/tmux.tera
Normal file
25
config-files/.config/tmux/plugins/theme/tmux.tera
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
whiskers:
|
||||
version: "2.1.1"
|
||||
matrix:
|
||||
- flavor
|
||||
filename: "themes/catppuccin_{{flavor.identifier}}.tmuxtheme"
|
||||
---
|
||||
{%- set palette = flavor.colors -%}
|
||||
# NOTE: you can use vars with $<var> and ${<var>} as long as the str is double quoted: ""
|
||||
# WARNING: hex colors can't contain capital letters
|
||||
|
||||
# --> Catppuccin ({{ flavor.identifier | capitalize }})
|
||||
thm_bg="#{{ palette.base.hex | lower }}"
|
||||
thm_fg="#{{ palette.text.hex | lower }}"
|
||||
thm_cyan="#{{ palette.sky.hex| lower }}"
|
||||
thm_black="#{{ palette.mantle.hex | lower }}"
|
||||
thm_gray="#{{ palette.surface0.hex | lower }}"
|
||||
thm_magenta="#{{ palette.mauve.hex | lower }}"
|
||||
thm_pink="#{{ palette.pink.hex | lower }}"
|
||||
thm_red="#{{ palette.red.hex | lower }}"
|
||||
thm_green="#{{ palette.green.hex | lower }}"
|
||||
thm_yellow="#{{ palette.yellow.hex | lower }}"
|
||||
thm_blue="#{{ palette.blue.hex | lower }}"
|
||||
thm_orange="#{{ palette.peach.hex | lower }}"
|
||||
thm_black4="#{{ palette.surface2.hex | lower }}"
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
do_color_interpolation() {
|
||||
local all_interpolated="$1"
|
||||
|
||||
for ((i=0; i<${#color_interpolation[@]}; i++)); do
|
||||
all_interpolated=${all_interpolated//${color_interpolation[$i]}/${color_values[$i]}}
|
||||
done
|
||||
|
||||
echo "$all_interpolated"
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
load_modules() {
|
||||
local modules_list=$1
|
||||
shift
|
||||
local module_directories=("$@")
|
||||
|
||||
local -i module_index=0;
|
||||
local module_name
|
||||
local module_path
|
||||
local loaded_modules
|
||||
local IN=$modules_list
|
||||
|
||||
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash#15988793
|
||||
while [ "$IN" != "$iter" ] ;do
|
||||
# extract the substring from start of string up to delimiter.
|
||||
iter=${IN%% *}
|
||||
# delete this first "element" AND next separator, from $IN.
|
||||
IN="${IN#"$iter "}"
|
||||
# Print (or doing anything with) the first "element".
|
||||
|
||||
module_name=$iter
|
||||
|
||||
for module_dir in "${module_directories[@]}" ; do
|
||||
module_path="$module_dir/$module_name.sh"
|
||||
|
||||
if [ -r "$module_path" ]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$module_path"
|
||||
loaded_modules="$loaded_modules$( "show_$module_name" "$module_index" )"
|
||||
module_index+=1
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${module_name/ }" ]]; then
|
||||
if [[ -z "${modules_list/ }" ]]; then
|
||||
tmux_echo "catppuccin warning: a module list has only white space, to remove all modules set it to \\\"null\\\"" 100
|
||||
else
|
||||
tmux_echo "catppuccin warning: a module list with value \\\"$modules_list\\\" has leading/trailing whitespace" 101
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
tmux_echo "catppuccin warning: module $module_name not found" 102
|
||||
|
||||
|
||||
done
|
||||
|
||||
echo "$loaded_modules"
|
||||
}
|
||||
151
config-files/.config/tmux/plugins/theme/utils/tmux_utils.sh
Normal file
151
config-files/.config/tmux/plugins/theme/utils/tmux_utils.sh
Normal file
@@ -0,0 +1,151 @@
|
||||
#!/bin/sh
|
||||
|
||||
tmux_echo() {
|
||||
local hook
|
||||
hook="after-new-session[$2]"
|
||||
|
||||
tmux set-hook -g "$hook" "run-shell 'echo -e \"$1\"'; set-hook -gu \"$hook\""
|
||||
}
|
||||
|
||||
get_tmux_option() {
|
||||
local option value default
|
||||
option="$1"
|
||||
default="$2"
|
||||
value=$(tmux show-option -gqv "$option")
|
||||
|
||||
if [ -n "$value" ]
|
||||
then
|
||||
if [ "$value" = "null" ]
|
||||
then
|
||||
echo ""
|
||||
else
|
||||
echo "$value"
|
||||
fi
|
||||
else
|
||||
echo "$default"
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
get_interpolated_tmux_option() {
|
||||
local option value default
|
||||
option="$1"
|
||||
default="$2"
|
||||
value=$(tmux show-option -gqv "$option")
|
||||
|
||||
if [ -n "$value" ]
|
||||
then
|
||||
if [ "$value" = "null" ]
|
||||
then
|
||||
echo ""
|
||||
else
|
||||
do_color_interpolation "$value"
|
||||
fi
|
||||
else
|
||||
echo "$default"
|
||||
fi
|
||||
}
|
||||
|
||||
set() {
|
||||
local option=$1
|
||||
local value=$2
|
||||
tmux_commands+=(set-option -gq "$option" "$value" ";")
|
||||
}
|
||||
|
||||
setw() {
|
||||
local option=$1
|
||||
local value=$2
|
||||
tmux_commands+=(set-window-option -gq "$option" "$value" ";")
|
||||
}
|
||||
|
||||
get_tmux_batch_option() {
|
||||
local option default value
|
||||
option="$1"
|
||||
default="$2"
|
||||
|
||||
for option_index in "${!tmux_batch_options[@]}"; do
|
||||
IFS="" read -r read_option read_value <<<"${tmux_batch_options[$option_index]}"
|
||||
if [[ "$read_option" == "$option" ]]; then
|
||||
echo "$read_value"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$default"
|
||||
}
|
||||
|
||||
get_interpolated_tmux_batch_option() {
|
||||
local option default value
|
||||
option="$1"
|
||||
default="$2"
|
||||
|
||||
for option_index in "${!tmux_batch_options[@]}"; do
|
||||
IFS="" read -r read_option read_value <<<"${tmux_batch_options[$option_index]}"
|
||||
if [[ "$read_option" == "$option" ]]; then
|
||||
do_color_interpolation "$read_value"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$default"
|
||||
}
|
||||
|
||||
add_tmux_batch_option() {
|
||||
local option
|
||||
option="$1"
|
||||
|
||||
tmux_batch_options_commands+=("show-option -gq $option ;")
|
||||
}
|
||||
|
||||
set_tmux_batch_option() {
|
||||
local option value
|
||||
option="$1"
|
||||
value="$2"
|
||||
|
||||
# NOTE: don't check for duplicates just append
|
||||
# for option_index in "${!tmux_batch_options[@]}"; do
|
||||
# read -d '' -r read_option <<<"${tmux_batch_options[$option_index]}"
|
||||
# if [[ "$read_option" == "$option" ]]; then
|
||||
# tmux_batch_options["$option_index"]="$option$value"
|
||||
# return
|
||||
# fi
|
||||
# done
|
||||
|
||||
tmux_batch_options+=("$option$value")
|
||||
}
|
||||
|
||||
run_tmux_batch_commands() {
|
||||
local temp
|
||||
|
||||
# shellcheck disable=SC2048,SC2086,SC2162
|
||||
while IFS=' ' read option value; do
|
||||
if [ -n "$value" ]; then
|
||||
if [ "$value" = "null" ]; then
|
||||
set_tmux_batch_option "$option" ""
|
||||
else
|
||||
temp="${value%\"}"
|
||||
temp="${temp#\"}"
|
||||
set_tmux_batch_option "$option" "$temp"
|
||||
fi
|
||||
fi
|
||||
done < <(tmux ${tmux_batch_options_commands[*]})
|
||||
|
||||
tmux_batch_options_commands=()
|
||||
}
|
||||
|
||||
tmux_batch_setup_status_module() {
|
||||
local name="$1"
|
||||
|
||||
# Don't want to run commands set before since we can't update
|
||||
# `tmux_batch_options` for it
|
||||
# shellcheck disable=SC2034
|
||||
tmux_batch_options_commands=()
|
||||
|
||||
# No need to check previous options
|
||||
# shellcheck disable=SC2034
|
||||
tmux_batch_options=()
|
||||
|
||||
add_tmux_batch_option "@catppuccin_${name}_icon"
|
||||
add_tmux_batch_option "@catppuccin_${name}_color"
|
||||
add_tmux_batch_option "@catppuccin_${name}_text"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
show_window_current_format() {
|
||||
local number color background text fill current_window_format
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options_commands=()
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options=()
|
||||
|
||||
add_tmux_batch_option "@catppuccin_window_current_color"
|
||||
add_tmux_batch_option "@catppuccin_window_current_background"
|
||||
add_tmux_batch_option "@catppuccin_window_current_text"
|
||||
add_tmux_batch_option "@catppuccin_window_current_fill"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
number="#I"
|
||||
color=$(get_tmux_batch_option "@catppuccin_window_current_color" "$thm_orange")
|
||||
background=$(get_tmux_batch_option "@catppuccin_window_current_background" "$thm_bg")
|
||||
text="$(get_tmux_batch_option "@catppuccin_window_current_text" "#{b:pane_current_path}")" # use #W for application instead of directory
|
||||
fill="$(get_tmux_batch_option "@catppuccin_window_current_fill" "number")" # number, all, none
|
||||
|
||||
current_window_format=$(build_window_format "$number" "$color" "$background" "$text" "$fill" "current")
|
||||
|
||||
echo "$current_window_format"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
show_window_default_format() {
|
||||
local number color background text fill default_window_format
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options_commands=()
|
||||
# shellcheck disable=SC2034
|
||||
local tmux_batch_options=()
|
||||
|
||||
add_tmux_batch_option "@catppuccin_window_default_color"
|
||||
add_tmux_batch_option "@catppuccin_window_default_background"
|
||||
add_tmux_batch_option "@catppuccin_window_default_text"
|
||||
add_tmux_batch_option "@catppuccin_window_default_fill"
|
||||
|
||||
run_tmux_batch_commands
|
||||
|
||||
number="#I"
|
||||
color=$(get_tmux_batch_option "@catppuccin_window_default_color" "$thm_blue")
|
||||
background=$(get_tmux_batch_option "@catppuccin_window_default_background" "$thm_gray")
|
||||
text="$(get_tmux_batch_option "@catppuccin_window_default_text" "#{b:pane_current_path}")" # use #W for application instead of directory
|
||||
fill="$(get_tmux_batch_option "@catppuccin_window_default_fill" "number")" # number, all, none
|
||||
|
||||
default_window_format=$(build_window_format "$number" "$color" "$background" "$text" "$fill" "default")
|
||||
|
||||
echo "$default_window_format"
|
||||
}
|
||||
62
config-files/.config/tmux/plugins/tmux-battery/battery.tmux
Executable file
62
config-files/.config/tmux/plugins/tmux-battery/battery.tmux
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/scripts/helpers.sh"
|
||||
|
||||
battery_interpolation=(
|
||||
"\#{battery_color_bg}"
|
||||
"\#{battery_color_fg}"
|
||||
"\#{battery_color_charge_bg}"
|
||||
"\#{battery_color_charge_fg}"
|
||||
"\#{battery_color_status_bg}"
|
||||
"\#{battery_color_status_fg}"
|
||||
"\#{battery_graph}"
|
||||
"\#{battery_icon}"
|
||||
"\#{battery_icon_charge}"
|
||||
"\#{battery_icon_status}"
|
||||
"\#{battery_percentage}"
|
||||
"\#{battery_remain}"
|
||||
)
|
||||
|
||||
battery_commands=(
|
||||
"#($CURRENT_DIR/scripts/battery_color.sh bg)"
|
||||
"#($CURRENT_DIR/scripts/battery_color.sh fg)"
|
||||
"#($CURRENT_DIR/scripts/battery_color_charge.sh bg)"
|
||||
"#($CURRENT_DIR/scripts/battery_color_charge.sh fg)"
|
||||
"#($CURRENT_DIR/scripts/battery_color_status.sh bg)"
|
||||
"#($CURRENT_DIR/scripts/battery_color_status.sh fg)"
|
||||
"#($CURRENT_DIR/scripts/battery_graph.sh)"
|
||||
"#($CURRENT_DIR/scripts/battery_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/battery_icon_charge.sh)"
|
||||
"#($CURRENT_DIR/scripts/battery_icon_status.sh)"
|
||||
"#($CURRENT_DIR/scripts/battery_percentage.sh)"
|
||||
"#($CURRENT_DIR/scripts/battery_remain.sh)"
|
||||
)
|
||||
|
||||
set_tmux_option() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
tmux set-option -gq "$option" "$value"
|
||||
}
|
||||
|
||||
do_interpolation() {
|
||||
local all_interpolated="$1"
|
||||
for ((i=0; i<${#battery_commands[@]}; i++)); do
|
||||
all_interpolated=${all_interpolated//${battery_interpolation[$i]}/${battery_commands[$i]}}
|
||||
done
|
||||
echo "$all_interpolated"
|
||||
}
|
||||
|
||||
update_tmux_option() {
|
||||
local option="$1"
|
||||
local option_value="$(get_tmux_option "$option")"
|
||||
local new_option_value="$(do_interpolation "$option_value")"
|
||||
set_tmux_option "$option" "$new_option_value"
|
||||
}
|
||||
|
||||
main() {
|
||||
update_tmux_option "status-right"
|
||||
update_tmux_option "status-left"
|
||||
}
|
||||
main
|
||||
23
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_color.sh
Executable file
23
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_color.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
print_color() {
|
||||
local plane="$1"
|
||||
local status="$2"
|
||||
if [ "$status" == "discharging" ]; then
|
||||
$CURRENT_DIR/battery_color_charge.sh "$plane"
|
||||
else
|
||||
$CURRENT_DIR/battery_color_status.sh "$plane" "$status"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local status="$(battery_status)"
|
||||
local plane="$1"
|
||||
print_color "$plane" "$status"
|
||||
}
|
||||
|
||||
main $@
|
||||
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
color_charge_primary_tier8=''
|
||||
color_charge_primary_tier7=''
|
||||
color_charge_primary_tier6=''
|
||||
color_charge_primary_tier5=''
|
||||
color_charge_primary_tier4=''
|
||||
color_charge_primary_tier3=''
|
||||
color_charge_primary_tier2=''
|
||||
color_charge_primary_tier1=''
|
||||
color_charge_secondary_tier8=''
|
||||
color_charge_secondary_tier7=''
|
||||
color_charge_secondary_tier6=''
|
||||
color_charge_secondary_tier5=''
|
||||
color_charge_secondary_tier4=''
|
||||
color_charge_secondary_tier3=''
|
||||
color_charge_secondary_tier2=''
|
||||
color_charge_secondary_tier1=''
|
||||
|
||||
# script default variables
|
||||
color_charge_primary_tier8_default='#00ff00'
|
||||
color_charge_primary_tier7_default='#55ff00'
|
||||
color_charge_primary_tier6_default='#aaff00'
|
||||
color_charge_primary_tier5_default='#ffff00'
|
||||
color_charge_primary_tier4_default='#ffc000'
|
||||
color_charge_primary_tier3_default='#ff8000'
|
||||
color_charge_primary_tier2_default='#ff4000'
|
||||
color_charge_primary_tier1_default='#ff0000'
|
||||
color_charge_secondary_tier8_default='colour0'
|
||||
color_charge_secondary_tier7_default='colour0'
|
||||
color_charge_secondary_tier6_default='colour0'
|
||||
color_charge_secondary_tier5_default='colour0'
|
||||
color_charge_secondary_tier4_default='colour0'
|
||||
color_charge_secondary_tier3_default='colour0'
|
||||
color_charge_secondary_tier2_default='colour0'
|
||||
color_charge_secondary_tier1_default='colour0'
|
||||
|
||||
# colors are set as script global variables
|
||||
get_color_charge_settings() {
|
||||
color_charge_primary_tier8=$(get_tmux_option "@batt_color_charge_primary_tier8" "$color_charge_primary_tier8_default")
|
||||
color_charge_primary_tier7=$(get_tmux_option "@batt_color_charge_primary_tier7" "$color_charge_primary_tier7_default")
|
||||
color_charge_primary_tier6=$(get_tmux_option "@batt_color_charge_primary_tier6" "$color_charge_primary_tier6_default")
|
||||
color_charge_primary_tier5=$(get_tmux_option "@batt_color_charge_primary_tier5" "$color_charge_primary_tier5_default")
|
||||
color_charge_primary_tier4=$(get_tmux_option "@batt_color_charge_primary_tier4" "$color_charge_primary_tier4_default")
|
||||
color_charge_primary_tier3=$(get_tmux_option "@batt_color_charge_primary_tier3" "$color_charge_primary_tier3_default")
|
||||
color_charge_primary_tier2=$(get_tmux_option "@batt_color_charge_primary_tier2" "$color_charge_primary_tier2_default")
|
||||
color_charge_primary_tier1=$(get_tmux_option "@batt_color_charge_primary_tier1" "$color_charge_primary_tier1_default")
|
||||
color_charge_secondary_tier8=$(get_tmux_option "@batt_color_charge_secondary_tier8" "$color_charge_secondary_tier8_default")
|
||||
color_charge_secondary_tier7=$(get_tmux_option "@batt_color_charge_secondary_tier7" "$color_charge_secondary_tier7_default")
|
||||
color_charge_secondary_tier6=$(get_tmux_option "@batt_color_charge_secondary_tier6" "$color_charge_secondary_tier6_default")
|
||||
color_charge_secondary_tier5=$(get_tmux_option "@batt_color_charge_secondary_tier5" "$color_charge_secondary_tier5_default")
|
||||
color_charge_secondary_tier4=$(get_tmux_option "@batt_color_charge_secondary_tier4" "$color_charge_secondary_tier4_default")
|
||||
color_charge_secondary_tier3=$(get_tmux_option "@batt_color_charge_secondary_tier3" "$color_charge_secondary_tier3_default")
|
||||
color_charge_secondary_tier2=$(get_tmux_option "@batt_color_charge_secondary_tier2" "$color_charge_secondary_tier2_default")
|
||||
color_charge_secondary_tier1=$(get_tmux_option "@batt_color_charge_secondary_tier1" "$color_charge_secondary_tier1_default")
|
||||
}
|
||||
|
||||
print_color_charge() {
|
||||
local primary_plane="$1"
|
||||
local secondary_plane=""
|
||||
if [ "$primary_plane" == "bg" ]; then
|
||||
secondary_plane="fg"
|
||||
else
|
||||
secondary_plane="bg"
|
||||
fi
|
||||
percentage=$($CURRENT_DIR/battery_percentage.sh | sed -e 's/%//')
|
||||
if [ $percentage -ge 95 -o "$percentage" == "" ]; then
|
||||
# if percentage is empty, assume it's a desktop
|
||||
printf "#[$primary_plane=$color_charge_primary_tier8${color_charge_secondary_tier8:+",$secondary_plane=$color_charge_secondary_tier8"}]"
|
||||
elif [ $percentage -ge 80 ]; then
|
||||
printf "#[$primary_plane=$color_charge_primary_tier7${color_charge_secondary_tier7:+",$secondary_plane=$color_charge_secondary_tier7"}]"
|
||||
elif [ $percentage -ge 65 ]; then
|
||||
printf "#[$primary_plane=$color_charge_primary_tier6${color_charge_secondary_tier6:+",$secondary_plane=$color_charge_secondary_tier6"}]"
|
||||
elif [ $percentage -ge 50 ]; then
|
||||
printf "#[$primary_plane=$color_charge_primary_tier5${color_charge_secondary_tier5:+",$secondary_plane=$color_charge_secondary_tier5"}]"
|
||||
elif [ $percentage -ge 35 ]; then
|
||||
printf "#[$primary_plane=$color_charge_primary_tier4${color_charge_secondary_tier4:+",$secondary_plane=$color_charge_secondary_tier4"}]"
|
||||
elif [ $percentage -ge 20 ]; then
|
||||
printf "#[$primary_plane=$color_charge_primary_tier3${color_charge_secondary_tier3:+",$secondary_plane=$color_charge_secondary_tier3"}]"
|
||||
elif [ $percentage -gt 5 ]; then
|
||||
printf "#[$primary_plane=$color_charge_primary_tier2${color_charge_secondary_tier2:+",$secondary_plane=$color_charge_secondary_tier2"}]"
|
||||
else
|
||||
printf "#[$primary_plane=$color_charge_primary_tier1${color_charge_secondary_tier1:+",$secondary_plane=$color_charge_secondary_tier1"}]"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local plane="$1"
|
||||
get_color_charge_settings
|
||||
print_color_charge "$plane"
|
||||
}
|
||||
|
||||
main $@
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
color_status_primary_charged=''
|
||||
color_status_primary_charging=''
|
||||
color_status_primary_discharging=''
|
||||
color_status_primary_attached=''
|
||||
color_status_primary_unknown=''
|
||||
color_status_secondary_charged=''
|
||||
color_status_secondary_charging=''
|
||||
color_status_secondary_discharging=''
|
||||
color_status_secondary_attached=''
|
||||
color_status_secondary_unknown=''
|
||||
|
||||
# script default variables
|
||||
color_status_primary_charged_default='colour33'
|
||||
color_status_primary_charging_default='colour33'
|
||||
color_status_primary_discharging_default='colour14'
|
||||
color_status_primary_attached_default='colour201'
|
||||
color_status_primary_unknown_default='colour7'
|
||||
color_status_secondary_charged_default='colour0'
|
||||
color_status_secondary_charging_default='colour0'
|
||||
color_status_secondary_discharging_default='colour0'
|
||||
color_status_secondary_attached_default='colour0'
|
||||
color_status_secondary_unknown_default='colour0'
|
||||
|
||||
# colors are set as script global variables
|
||||
get_color_status_settings() {
|
||||
color_status_primary_charged=$(get_tmux_option "@batt_color_status_primary_charged" "$color_status_primary_charged_default")
|
||||
color_status_primary_charging=$(get_tmux_option "@batt_color_status_primary_charging" "$color_status_primary_charging_default")
|
||||
color_status_primary_discharging=$(get_tmux_option "@batt_color_status_primary_discharging" "$color_status_primary_discharging_default")
|
||||
color_status_primary_attached=$(get_tmux_option "@batt_color_status_primary_attached" "$color_status_primary_attached_default")
|
||||
color_status_primary_unknown=$(get_tmux_option "@batt_color_status_primary_unknown" "$color_status_primary_unknown_default")
|
||||
color_status_secondary_charged=$(get_tmux_option "@batt_color_status_secondary_charged" "$color_status_secondary_charged_default")
|
||||
color_status_secondary_charging=$(get_tmux_option "@batt_color_status_secondary_charging" "$color_status_secondary_charging_default")
|
||||
color_status_secondary_discharging=$(get_tmux_option "@batt_color_status_secondary_discharging" "$color_status_secondary_discharging_default")
|
||||
color_status_secondary_attached=$(get_tmux_option "@batt_color_status_secondary_attached" "$color_status_secondary_attached_default")
|
||||
color_status_secondary_unknown=$(get_tmux_option "@batt_color_status_secondary_unknown" "$color_status_secondary_unknown_default")
|
||||
}
|
||||
|
||||
print_color_status() {
|
||||
local plane_primary="$1"
|
||||
local plane_secondary=""
|
||||
if [ "$plane_primary" == "bg" ]; then
|
||||
plane_secondary="fg"
|
||||
else
|
||||
plane_secondary="bg"
|
||||
fi
|
||||
local status="$2"
|
||||
if [[ $status =~ (charged) || $status =~ (full) ]]; then
|
||||
printf "#[$plane_primary=$color_status_primary_charged${color_status_secondary_charged:+",$plane_secondary=$color_status_secondary_charged"}]"
|
||||
elif [[ $status =~ (^charging) ]]; then
|
||||
printf "#[$plane_primary=$color_status_primary_charging${color_status_secondary_charging:+",$plane_secondary=$color_status_secondary_charging"}]"
|
||||
elif [[ $status =~ (^discharging) ]]; then
|
||||
printf "#[$plane_primary=$color_status_primary_discharging${color_status_secondary_discharging:+",$plane_secondary=$color_status_secondary_discharging"}]"
|
||||
elif [[ $status =~ (attached) ]]; then
|
||||
printf "#[$plane_primary=$color_status_primary_attached${color_status_secondary_attached:+",$plane_secondary=$color_status_secondary_attached"}]"
|
||||
else
|
||||
printf "#[$plane_primary=$color_status_primary_unknown${color_status_secondary_unknown:+",$plane_secondary=$color_status_secondary_unknown"}]"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local plane="$1"
|
||||
local status=${2:-$(battery_status)}
|
||||
get_color_status_settings
|
||||
print_color_status "$plane" "$status"
|
||||
}
|
||||
|
||||
main $@
|
||||
45
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_graph.sh
Executable file
45
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_graph.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
print_graph() {
|
||||
local percentage=$1
|
||||
if [ $percentage -gt 5 ]; then
|
||||
printf "▁"
|
||||
else
|
||||
printf " "
|
||||
fi
|
||||
if [ $percentage -ge 25 ]; then
|
||||
printf "▂"
|
||||
else
|
||||
printf " "
|
||||
fi
|
||||
if [ $percentage -ge 50 ]; then
|
||||
printf "▄"
|
||||
else
|
||||
printf " "
|
||||
fi
|
||||
if [ $percentage -ge 75 ]; then
|
||||
printf "▆"
|
||||
else
|
||||
printf " "
|
||||
fi
|
||||
if [ $percentage -ge 95 ]; then
|
||||
printf "█"
|
||||
else
|
||||
printf " "
|
||||
echo "▇"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local percentage=$($CURRENT_DIR/battery_percentage.sh)
|
||||
if [ "$(uname)" == "OpenBSD" ]; then
|
||||
print_graph ${percentage}
|
||||
else
|
||||
print_graph ${percentage%?}
|
||||
fi
|
||||
}
|
||||
main
|
||||
21
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_icon.sh
Executable file
21
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_icon.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
print_icon() {
|
||||
local status=$1
|
||||
if [ "$status" == "discharging" ]; then
|
||||
$CURRENT_DIR/battery_icon_charge.sh
|
||||
else
|
||||
$CURRENT_DIR/battery_icon_status.sh "$status"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local status=$(battery_status)
|
||||
print_icon "$status"
|
||||
}
|
||||
|
||||
main
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
icon_charge_tier8=''
|
||||
icon_charge_tier7=''
|
||||
icon_charge_tier6=''
|
||||
icon_charge_tier5=''
|
||||
icon_charge_tier4=''
|
||||
icon_charge_tier3=''
|
||||
icon_charge_tier2=''
|
||||
icon_charge_tier1=''
|
||||
|
||||
# script default variables
|
||||
icon_charge_tier8_default='█'
|
||||
icon_charge_tier7_default='▇'
|
||||
icon_charge_tier6_default='▆'
|
||||
icon_charge_tier5_default='▅'
|
||||
icon_charge_tier4_default='▄'
|
||||
icon_charge_tier3_default='▃'
|
||||
icon_charge_tier2_default='▂'
|
||||
icon_charge_tier1_default='▁'
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_charge_settings() {
|
||||
icon_charge_tier8=$(get_tmux_option "@batt_icon_charge_tier8" "$icon_charge_tier8_default")
|
||||
icon_charge_tier7=$(get_tmux_option "@batt_icon_charge_tier7" "$icon_charge_tier7_default")
|
||||
icon_charge_tier6=$(get_tmux_option "@batt_icon_charge_tier6" "$icon_charge_tier6_default")
|
||||
icon_charge_tier5=$(get_tmux_option "@batt_icon_charge_tier5" "$icon_charge_tier5_default")
|
||||
icon_charge_tier4=$(get_tmux_option "@batt_icon_charge_tier4" "$icon_charge_tier4_default")
|
||||
icon_charge_tier3=$(get_tmux_option "@batt_icon_charge_tier3" "$icon_charge_tier3_default")
|
||||
icon_charge_tier2=$(get_tmux_option "@batt_icon_charge_tier2" "$icon_charge_tier2_default")
|
||||
icon_charge_tier1=$(get_tmux_option "@batt_icon_charge_tier1" "$icon_charge_tier1_default")
|
||||
}
|
||||
|
||||
print_icon_charge() {
|
||||
percentage=$($CURRENT_DIR/battery_percentage.sh | sed -e 's/%//')
|
||||
if [ $percentage -ge 95 -o "$percentage" == "" ]; then
|
||||
# if percentage is empty, assume it's a desktop
|
||||
printf "$icon_charge_tier8"
|
||||
elif [ $percentage -ge 80 ]; then
|
||||
printf "$icon_charge_tier7"
|
||||
elif [ $percentage -ge 65 ]; then
|
||||
printf "$icon_charge_tier6"
|
||||
elif [ $percentage -ge 50 ]; then
|
||||
printf "$icon_charge_tier5"
|
||||
elif [ $percentage -ge 35 ]; then
|
||||
printf "$icon_charge_tier4"
|
||||
elif [ $percentage -ge 20 ]; then
|
||||
printf "$icon_charge_tier3"
|
||||
elif [ $percentage -gt 5 ]; then
|
||||
printf "$icon_charge_tier2"
|
||||
else
|
||||
printf "$icon_charge_tier1"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_charge_settings
|
||||
print_icon_charge
|
||||
}
|
||||
|
||||
main
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
icon_status_charged=''
|
||||
icon_status_charging=''
|
||||
icon_status_discharging=''
|
||||
icon_status_attached=''
|
||||
icon_status_unknown=''
|
||||
|
||||
# script default variables
|
||||
icon_status_charged_default='🔌'
|
||||
icon_status_charged_default_osx='🔌'
|
||||
icon_status_charging_default='🔌'
|
||||
icon_status_discharging_default='🔋'
|
||||
icon_status_attached_default='⚠️'
|
||||
icon_status_unknown_default='?'
|
||||
|
||||
# determine which charged_default variable to use
|
||||
get_icon_status_charged_default() {
|
||||
if is_osx; then
|
||||
printf "$icon_status_charged_default_osx"
|
||||
else
|
||||
printf "$icon_status_charged_default"
|
||||
fi
|
||||
}
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_status_settings() {
|
||||
icon_status_charged=$(get_tmux_option "@batt_icon_status_charged" "$(get_icon_status_charged_default)")
|
||||
icon_status_charging=$(get_tmux_option "@batt_icon_status_charging" "$icon_status_charging_default")
|
||||
icon_status_discharging=$(get_tmux_option "@batt_icon_status_discharging" "$icon_status_discharging_default")
|
||||
icon_status_attached=$(get_tmux_option "@batt_icon_status_attached" "$icon_status_attached_default")
|
||||
icon_status_unknown=$(get_tmux_option "@batt_icon_status_unknown" "$icon_status_unknown_default")
|
||||
}
|
||||
|
||||
print_icon_status() {
|
||||
local status=$1
|
||||
if [[ $status =~ (charged) || $status =~ (full) ]]; then
|
||||
printf "$icon_status_charged"
|
||||
elif [[ $status =~ (^charging) ]]; then
|
||||
printf "$icon_status_charging"
|
||||
elif [[ $status =~ (^discharging) ]]; then
|
||||
printf "$icon_status_discharging"
|
||||
elif [[ $status =~ (attached) ]]; then
|
||||
printf "$icon_status_attached"
|
||||
else
|
||||
printf "$icon_status_unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_status_settings
|
||||
local status=${1:-$(battery_status)}
|
||||
print_icon_status "$status"
|
||||
}
|
||||
|
||||
main
|
||||
45
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_percentage.sh
Executable file
45
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_percentage.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
print_battery_percentage() {
|
||||
# percentage displayed in the 2nd field of the 2nd row
|
||||
if is_wsl; then
|
||||
local battery
|
||||
battery=$(find /sys/class/power_supply/*/capacity | tail -n1)
|
||||
cat "$battery"
|
||||
elif command_exists "pmset"; then
|
||||
pmset -g batt | grep -o "[0-9]\{1,3\}%"
|
||||
elif command_exists "acpi"; then
|
||||
acpi -b | grep -m 1 -Eo "[0-9]+%"
|
||||
elif command_exists "upower"; then
|
||||
# use DisplayDevice if available otherwise battery
|
||||
local battery=$(upower -e | grep -E 'battery|DisplayDevice'| tail -n1)
|
||||
if [ -z "$battery" ]; then
|
||||
return
|
||||
fi
|
||||
local percentage=$(upower -i $battery | awk '/percentage:/ {print $2}')
|
||||
if [ "$percentage" ]; then
|
||||
echo ${percentage%.*%}
|
||||
return
|
||||
fi
|
||||
local energy
|
||||
local energy_full
|
||||
energy=$(upower -i $battery | awk -v nrg="$energy" '/energy:/ {print nrg+$2}')
|
||||
energy_full=$(upower -i $battery | awk -v nrgfull="$energy_full" '/energy-full:/ {print nrgfull+$2}')
|
||||
if [ -n "$energy" ] && [ -n "$energy_full" ]; then
|
||||
echo $energy $energy_full | awk '{printf("%d%%", ($1/$2)*100)}'
|
||||
fi
|
||||
elif command_exists "termux-battery-status"; then
|
||||
termux-battery-status | jq -r '.percentage' | awk '{printf("%d%%", $1)}'
|
||||
elif command_exists "apm"; then
|
||||
apm -l
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
print_battery_percentage
|
||||
}
|
||||
main
|
||||
134
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_remain.sh
Executable file
134
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_remain.sh
Executable file
@@ -0,0 +1,134 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
short=false
|
||||
|
||||
get_remain_settings() {
|
||||
short=$(get_tmux_option "@batt_remain_short" false)
|
||||
}
|
||||
|
||||
battery_discharging() {
|
||||
local status="$(battery_status)"
|
||||
[[ $status =~ (discharging) ]]
|
||||
}
|
||||
|
||||
battery_charged() {
|
||||
local status="$(battery_status)"
|
||||
[[ $status =~ (charged) || $status =~ (full) ]]
|
||||
}
|
||||
|
||||
|
||||
convertmins() {
|
||||
((h=${1}/60))
|
||||
((m=${1}%60))
|
||||
printf "%02d:%02d\n" $h $m $s
|
||||
}
|
||||
|
||||
apm_battery_remaining_time() {
|
||||
local remaining_time="$(convertmins $(apm -m))"
|
||||
if battery_discharging; then
|
||||
if $short; then
|
||||
echo $remaining_time | awk '{printf "~%s", $1}'
|
||||
else
|
||||
echo $remaining_time | awk '{printf "- %s left", $1}'
|
||||
fi
|
||||
elif battery_charged; then
|
||||
if $short; then
|
||||
echo $remaining_time | awk '{printf "charged", $1}'
|
||||
else
|
||||
echo $remaining_time | awk '{printf "fully charged", $1}'
|
||||
fi
|
||||
else
|
||||
echo "charging"
|
||||
fi
|
||||
}
|
||||
|
||||
pmset_battery_remaining_time() {
|
||||
local status="$(pmset -g batt)"
|
||||
if echo $status | grep 'no estimate' >/dev/null 2>&1; then
|
||||
if $short; then
|
||||
echo '~?:??'
|
||||
else
|
||||
echo '- Calculating estimate...'
|
||||
fi
|
||||
else
|
||||
local remaining_time="$(echo $status | grep -o '[0-9]\{1,2\}:[0-9]\{1,2\}')"
|
||||
if battery_discharging; then
|
||||
if $short; then
|
||||
echo $remaining_time | awk '{printf "~%s", $1}'
|
||||
else
|
||||
echo $remaining_time | awk '{printf "- %s left", $1}'
|
||||
fi
|
||||
elif battery_charged; then
|
||||
if $short; then
|
||||
echo $remaining_time | awk '{printf "charged", $1}'
|
||||
else
|
||||
echo $remaining_time | awk '{printf "fully charged", $1}'
|
||||
fi
|
||||
else
|
||||
if $short; then
|
||||
echo $remaining_time | awk '{printf "~%s", $1}'
|
||||
else
|
||||
echo $remaining_time | awk '{printf "- %s till full", $1}'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
upower_battery_remaining_time() {
|
||||
battery=$(upower -e | grep -E 'battery|DisplayDevice'| tail -n1)
|
||||
if battery_discharging; then
|
||||
local remaining_time
|
||||
remaining_time=$(upower -i "$battery" | grep -E '(remain|time to empty)')
|
||||
if $short; then
|
||||
echo "$remaining_time" | awk '{printf "%s %s", $(NF-1), $(NF)}'
|
||||
else
|
||||
echo "$remaining_time" | awk '{printf "%s %s left", $(NF-1), $(NF)}'
|
||||
fi
|
||||
elif battery_charged; then
|
||||
if $short; then
|
||||
echo ""
|
||||
else
|
||||
echo "charged"
|
||||
fi
|
||||
else
|
||||
local remaining_time
|
||||
remaining_time=$(upower -i "$battery" | grep -E 'time to full')
|
||||
if $short; then
|
||||
echo "$remaining_time" | awk '{printf "%s %s", $(NF-1), $(NF)}'
|
||||
else
|
||||
echo "$remaining_time" | awk '{printf "%s %s to full", $(NF-1), $(NF)}'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
acpi_battery_remaining_time() {
|
||||
regex="[0-9]+:[0-9]+"
|
||||
if ! $short; then
|
||||
regex="$regex:[0-9]+"
|
||||
fi
|
||||
acpi -b | grep -m 1 -Eo "$regex"
|
||||
}
|
||||
|
||||
print_battery_remain() {
|
||||
if is_wsl; then
|
||||
echo "?" # currently unsupported on WSL
|
||||
elif command_exists "pmset"; then
|
||||
pmset_battery_remaining_time
|
||||
elif command_exists "acpi"; then
|
||||
acpi_battery_remaining_time
|
||||
elif command_exists "upower"; then
|
||||
upower_battery_remaining_time
|
||||
elif command_exists "apm"; then
|
||||
apm_battery_remaining_time
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_remain_settings
|
||||
print_battery_remain
|
||||
}
|
||||
main
|
||||
50
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_status_bg.sh
Executable file
50
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_status_bg.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
color_full_charge_default="#[bg=green]"
|
||||
color_high_charge_default="#[bg=yellow]"
|
||||
color_medium_charge_default="#[bg=colour208]" # orange
|
||||
color_low_charge_default="#[bg=red]"
|
||||
color_charging_default="#[bg=green]"
|
||||
|
||||
color_full_charge=""
|
||||
color_high_charge=""
|
||||
color_medium_charge=""
|
||||
color_low_charge=""
|
||||
color_charging=""
|
||||
|
||||
get_charge_color_settings() {
|
||||
color_full_charge=$(get_tmux_option "@batt_color_full_charge" "$color_full_charge_default")
|
||||
color_high_charge=$(get_tmux_option "@batt_color_high_charge" "$color_high_charge_default")
|
||||
color_medium_charge=$(get_tmux_option "@batt_color_medium_charge" "$color_medium_charge_default")
|
||||
color_low_charge=$(get_tmux_option "@batt_color_low_charge" "$color_low_charge_default")
|
||||
color_charging=$(get_tmux_option "@batt_color_charging" "$color_charging_default")
|
||||
}
|
||||
|
||||
print_battery_status_bg() {
|
||||
# Call `battery_percentage.sh`.
|
||||
percentage=$($CURRENT_DIR/battery_percentage.sh | sed -e 's/%//')
|
||||
status=$(battery_status | awk '{print $1;}')
|
||||
if [ $status == 'charging' ]; then
|
||||
printf $color_charging
|
||||
elif [ $percentage -eq 100 ]; then
|
||||
printf $color_full_charge
|
||||
elif [ $percentage -le 99 -a $percentage -ge 51 ];then
|
||||
printf $color_high_charge
|
||||
elif [ $percentage -le 50 -a $percentage -ge 16 ];then
|
||||
printf $color_medium_charge
|
||||
elif [ "$percentage" == "" ];then
|
||||
printf $color_full_charge_default # assume it's a desktop
|
||||
else
|
||||
printf $color_low_charge
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_charge_color_settings
|
||||
print_battery_status_bg
|
||||
}
|
||||
main
|
||||
50
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_status_fg.sh
Executable file
50
config-files/.config/tmux/plugins/tmux-battery/scripts/battery_status_fg.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
color_full_charge_default="#[fg=green]"
|
||||
color_high_charge_default="#[fg=yellow]"
|
||||
color_medium_charge_default="#[fg=colour208]" # orange
|
||||
color_low_charge_default="#[fg=red]"
|
||||
color_charging_default="#[fg=green]"
|
||||
|
||||
color_full_charge=""
|
||||
color_high_charge=""
|
||||
color_medium_charge=""
|
||||
color_low_charge=""
|
||||
color_charging=""
|
||||
|
||||
get_charge_color_settings() {
|
||||
color_full_charge=$(get_tmux_option "@batt_color_full_charge" "$color_full_charge_default")
|
||||
color_high_charge=$(get_tmux_option "@batt_color_high_charge" "$color_high_charge_default")
|
||||
color_medium_charge=$(get_tmux_option "@batt_color_medium_charge" "$color_medium_charge_default")
|
||||
color_low_charge=$(get_tmux_option "@batt_color_low_charge" "$color_low_charge_default")
|
||||
color_charging=$(get_tmux_option "@batt_color_charging" "$color_charging_default")
|
||||
}
|
||||
|
||||
print_battery_status_fg() {
|
||||
# Call `battery_percentage.sh`.
|
||||
percentage=$($CURRENT_DIR/battery_percentage.sh | sed -e 's/%//')
|
||||
status=$(battery_status | awk '{print $1;}')
|
||||
if [ $status == 'charging' ]; then
|
||||
printf $color_charging
|
||||
elif [ $percentage -eq 100 ]; then
|
||||
printf $color_full_charge
|
||||
elif [ $percentage -le 99 -a $percentage -ge 51 ];then
|
||||
printf $color_high_charge
|
||||
elif [ $percentage -le 50 -a $percentage -ge 16 ];then
|
||||
printf $color_medium_charge
|
||||
elif [ "$percentage" == "" ];then
|
||||
printf $color_full_charge_default # assume it's a desktop
|
||||
else
|
||||
printf $color_low_charge
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_charge_color_settings
|
||||
print_battery_status_fg
|
||||
}
|
||||
main
|
||||
@@ -0,0 +1,63 @@
|
||||
get_tmux_option() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value="$(tmux show-option -gqv "$option")"
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
echo "$option_value"
|
||||
fi
|
||||
}
|
||||
|
||||
is_osx() {
|
||||
[ $(uname) == "Darwin" ]
|
||||
}
|
||||
|
||||
is_chrome() {
|
||||
chrome="/sys/class/chromeos/cros_ec"
|
||||
if [ -d "$chrome" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_wsl() {
|
||||
version=$(</proc/version)
|
||||
if [[ "$version" == *"Microsoft"* || "$version" == *"microsoft"* ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
local command="$1"
|
||||
type "$command" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
battery_status() {
|
||||
if is_wsl; then
|
||||
local battery
|
||||
battery=$(find /sys/class/power_supply/*/status | tail -n1)
|
||||
awk '{print tolower($0);}' "$battery"
|
||||
elif command_exists "pmset"; then
|
||||
pmset -g batt | awk -F '; *' 'NR==2 { print $2 }'
|
||||
elif command_exists "acpi"; then
|
||||
acpi -b | awk '{gsub(/,/, ""); print tolower($3); exit}'
|
||||
elif command_exists "upower"; then
|
||||
local battery
|
||||
battery=$(upower -e | grep -E 'battery|DisplayDevice'| tail -n1)
|
||||
upower -i $battery | awk '/state/ {print $2}'
|
||||
elif command_exists "termux-battery-status"; then
|
||||
termux-battery-status | jq -r '.status' | awk '{printf("%s%", tolower($1))}'
|
||||
elif command_exists "apm"; then
|
||||
local battery
|
||||
battery=$(apm -a)
|
||||
if [ $battery -eq 0 ]; then
|
||||
echo "discharging"
|
||||
elif [ $battery -eq 1 ]; then
|
||||
echo "charging"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
88
config-files/.config/tmux/plugins/tmux-cpu/cpu.tmux
Executable file
88
config-files/.config/tmux/plugins/tmux-cpu/cpu.tmux
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
source "$CURRENT_DIR/scripts/helpers.sh"
|
||||
|
||||
cpu_interpolation=(
|
||||
"\#{cpu_percentage}"
|
||||
"\#{cpu_icon}"
|
||||
"\#{cpu_bg_color}"
|
||||
"\#{cpu_fg_color}"
|
||||
"\#{gpu_percentage}"
|
||||
"\#{gpu_icon}"
|
||||
"\#{gpu_bg_color}"
|
||||
"\#{gpu_fg_color}"
|
||||
"\#{ram_percentage}"
|
||||
"\#{ram_icon}"
|
||||
"\#{ram_bg_color}"
|
||||
"\#{ram_fg_color}"
|
||||
"\#{gram_percentage}"
|
||||
"\#{gram_icon}"
|
||||
"\#{gram_bg_color}"
|
||||
"\#{gram_fg_color}"
|
||||
"\#{cpu_temp}"
|
||||
"\#{cpu_temp_icon}"
|
||||
"\#{cpu_temp_bg_color}"
|
||||
"\#{cpu_temp_fg_color}"
|
||||
"\#{gpu_temp}"
|
||||
"\#{gpu_temp_icon}"
|
||||
"\#{gpu_temp_bg_color}"
|
||||
"\#{gpu_temp_fg_color}"
|
||||
)
|
||||
cpu_commands=(
|
||||
"#($CURRENT_DIR/scripts/cpu_percentage.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_fg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_percentage.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_fg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/ram_percentage.sh)"
|
||||
"#($CURRENT_DIR/scripts/ram_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/ram_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/ram_fg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_percentage.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gram_fg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_temp.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_temp_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_temp_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_temp_fg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_temp.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_temp_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_temp_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_temp_fg_color.sh)"
|
||||
)
|
||||
|
||||
set_tmux_option() {
|
||||
local option=$1
|
||||
local value=$2
|
||||
tmux set-option -gq "$option" "$value"
|
||||
}
|
||||
|
||||
do_interpolation() {
|
||||
local all_interpolated="$1"
|
||||
for ((i = 0; i < ${#cpu_commands[@]}; i++)); do
|
||||
all_interpolated=${all_interpolated//${cpu_interpolation[$i]}/${cpu_commands[$i]}}
|
||||
done
|
||||
echo "$all_interpolated"
|
||||
}
|
||||
|
||||
update_tmux_option() {
|
||||
local option
|
||||
local option_value
|
||||
local new_option_value
|
||||
option=$1
|
||||
option_value=$(get_tmux_option "$option")
|
||||
new_option_value=$(do_interpolation "$option_value")
|
||||
set_tmux_option "$option" "$new_option_value"
|
||||
}
|
||||
|
||||
main() {
|
||||
update_tmux_option "status-right"
|
||||
update_tmux_option "status-left"
|
||||
}
|
||||
main
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_bg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_bg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
cpu_low_bg_color=""
|
||||
cpu_medium_bg_color=""
|
||||
cpu_high_bg_color=""
|
||||
|
||||
cpu_low_default_bg_color="#[bg=green]"
|
||||
cpu_medium_default_bg_color="#[bg=yellow]"
|
||||
cpu_high_default_bg_color="#[bg=red]"
|
||||
|
||||
get_bg_color_settings() {
|
||||
cpu_low_bg_color=$(get_tmux_option "@cpu_low_bg_color" "$cpu_low_default_bg_color")
|
||||
cpu_medium_bg_color=$(get_tmux_option "@cpu_medium_bg_color" "$cpu_medium_default_bg_color")
|
||||
cpu_high_bg_color=$(get_tmux_option "@cpu_high_bg_color" "$cpu_high_default_bg_color")
|
||||
}
|
||||
|
||||
print_bg_color() {
|
||||
local cpu_percentage
|
||||
local load_status
|
||||
cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//')
|
||||
load_status=$(load_status "$cpu_percentage" "cpu")
|
||||
if [ "$load_status" == "low" ]; then
|
||||
echo "$cpu_low_bg_color"
|
||||
elif [ "$load_status" == "medium" ]; then
|
||||
echo "$cpu_medium_bg_color"
|
||||
elif [ "$load_status" == "high" ]; then
|
||||
echo "$cpu_high_bg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_bg_color_settings
|
||||
print_bg_color
|
||||
}
|
||||
main "$@"
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_fg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_fg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
cpu_low_fg_color=""
|
||||
cpu_medium_fg_color=""
|
||||
cpu_high_fg_color=""
|
||||
|
||||
cpu_low_default_fg_color="#[fg=green]"
|
||||
cpu_medium_default_fg_color="#[fg=yellow]"
|
||||
cpu_high_default_fg_color="#[fg=red]"
|
||||
|
||||
get_fg_color_settings() {
|
||||
cpu_low_fg_color=$(get_tmux_option "@cpu_low_fg_color" "$cpu_low_default_fg_color")
|
||||
cpu_medium_fg_color=$(get_tmux_option "@cpu_medium_fg_color" "$cpu_medium_default_fg_color")
|
||||
cpu_high_fg_color=$(get_tmux_option "@cpu_high_fg_color" "$cpu_high_default_fg_color")
|
||||
}
|
||||
|
||||
print_fg_color() {
|
||||
local cpu_percentage
|
||||
local load_status
|
||||
cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//')
|
||||
load_status=$(load_status "$cpu_percentage" "cpu")
|
||||
if [ "$load_status" == "low" ]; then
|
||||
echo "$cpu_low_fg_color"
|
||||
elif [ "$load_status" == "medium" ]; then
|
||||
echo "$cpu_medium_fg_color"
|
||||
elif [ "$load_status" == "high" ]; then
|
||||
echo "$cpu_high_fg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_fg_color_settings
|
||||
print_fg_color
|
||||
}
|
||||
main "$@"
|
||||
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_icon.sh
Executable file
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_icon.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
cpu_low_icon=""
|
||||
cpu_medium_icon=""
|
||||
cpu_high_icon=""
|
||||
|
||||
cpu_low_default_icon="="
|
||||
cpu_medium_default_icon="≡"
|
||||
cpu_high_default_icon="≣"
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_settings() {
|
||||
cpu_low_icon=$(get_tmux_option "@cpu_low_icon" "$cpu_low_default_icon")
|
||||
cpu_medium_icon=$(get_tmux_option "@cpu_medium_icon" "$cpu_medium_default_icon")
|
||||
cpu_high_icon=$(get_tmux_option "@cpu_high_icon" "$cpu_high_default_icon")
|
||||
}
|
||||
|
||||
print_icon() {
|
||||
local cpu_percentage
|
||||
local load_status
|
||||
cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//')
|
||||
load_status=$(load_status "$cpu_percentage" "cpu")
|
||||
if [ "$load_status" == "low" ]; then
|
||||
echo "$cpu_low_icon"
|
||||
elif [ "$load_status" == "medium" ]; then
|
||||
echo "$cpu_medium_icon"
|
||||
elif [ "$load_status" == "high" ]; then
|
||||
echo "$cpu_high_icon"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_settings
|
||||
print_icon "$1"
|
||||
}
|
||||
main "$@"
|
||||
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh
Executable file
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
cpu_percentage_format="%3.1f%%"
|
||||
|
||||
print_cpu_percentage() {
|
||||
cpu_percentage_format=$(get_tmux_option "@cpu_percentage_format" "$cpu_percentage_format")
|
||||
|
||||
if command_exists "iostat"; then
|
||||
|
||||
if is_linux_iostat; then
|
||||
cached_eval iostat -c 1 2 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$NF} END {printf(format, usage)}' | sed 's/,/./'
|
||||
elif is_osx; then
|
||||
cached_eval iostat -c 2 disk0 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$6} END {printf(format, usage)}' | sed 's/,/./'
|
||||
elif is_freebsd || is_openbsd; then
|
||||
cached_eval iostat -c 2 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$NF} END {printf(format, usage)}' | sed 's/,/./'
|
||||
else
|
||||
echo "Unknown iostat version please create an issue"
|
||||
fi
|
||||
elif command_exists "sar"; then
|
||||
cached_eval sar -u 1 1 | sed '/^\s*$/d' | tail -n 1 | awk -v format="$cpu_percentage_format" '{usage=100-$NF} END {printf(format, usage)}' | sed 's/,/./'
|
||||
else
|
||||
if is_cygwin; then
|
||||
usage="$(cached_eval WMIC cpu get LoadPercentage | grep -Eo '^[0-9]+')"
|
||||
# shellcheck disable=SC2059
|
||||
printf "$cpu_percentage_format" "$usage"
|
||||
else
|
||||
load=$(cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}')
|
||||
cpus=$(cpus_number)
|
||||
echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
print_cpu_percentage
|
||||
}
|
||||
main
|
||||
28
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp.sh
Executable file
28
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
cpu_temp_format="%2.0f"
|
||||
cpu_temp_unit="C"
|
||||
|
||||
print_cpu_temp() {
|
||||
cpu_temp_format=$(get_tmux_option "@cpu_temp_format" "$cpu_temp_format")
|
||||
cpu_temp_unit=$(get_tmux_option "@cpu_temp_unit" "$cpu_temp_unit")
|
||||
if command_exists "sensors"; then
|
||||
local val
|
||||
if [[ "$cpu_temp_unit" == F ]]; then
|
||||
val="$(sensors -f)"
|
||||
else
|
||||
val="$(sensors)"
|
||||
fi
|
||||
echo "$val" | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
print_cpu_temp
|
||||
}
|
||||
main
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp_bg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp_bg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
cpu_temp_low_bg_color=""
|
||||
cpu_temp_medium_bg_color=""
|
||||
cpu_temp_high_bg_color=""
|
||||
|
||||
cpu_temp_low_default_bg_color="#[bg=green]"
|
||||
cpu_temp_medium_default_bg_color="#[bg=yellow]"
|
||||
cpu_temp_high_default_bg_color="#[bg=red]"
|
||||
|
||||
get_bg_color_settings() {
|
||||
cpu_temp_low_bg_color=$(get_tmux_option "@cpu_temp_low_bg_color" "$cpu_temp_low_default_bg_color")
|
||||
cpu_temp_medium_bg_color=$(get_tmux_option "@cpu_temp_medium_bg_color" "$cpu_temp_medium_default_bg_color")
|
||||
cpu_temp_high_bg_color=$(get_tmux_option "@cpu_temp_high_bg_color" "$cpu_temp_high_default_bg_color")
|
||||
}
|
||||
|
||||
print_bg_color() {
|
||||
local cpu_temp
|
||||
local cpu_temp_status
|
||||
cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||
cpu_temp_status=$(temp_status "$cpu_temp")
|
||||
if [ "$cpu_temp_status" == "low" ]; then
|
||||
echo "$cpu_temp_low_bg_color"
|
||||
elif [ "$cpu_temp_status" == "medium" ]; then
|
||||
echo "$cpu_temp_medium_bg_color"
|
||||
elif [ "$cpu_temp_status" == "high" ]; then
|
||||
echo "$cpu_temp_high_bg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_bg_color_settings
|
||||
print_bg_color
|
||||
}
|
||||
main
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp_fg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp_fg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
cpu_temp_low_fg_color=""
|
||||
cpu_temp_medium_fg_color=""
|
||||
cpu_temp_high_fg_color=""
|
||||
|
||||
cpu_temp_low_default_fg_color="#[fg=green]"
|
||||
cpu_temp_medium_default_fg_color="#[fg=yellow]"
|
||||
cpu_temp_high_default_fg_color="#[fg=red]"
|
||||
|
||||
get_fg_color_settings() {
|
||||
cpu_temp_low_fg_color=$(get_tmux_option "@cpu_temp_low_fg_color" "$cpu_temp_low_default_fg_color")
|
||||
cpu_temp_medium_fg_color=$(get_tmux_option "@cpu_temp_medium_fg_color" "$cpu_temp_medium_default_fg_color")
|
||||
cpu_temp_high_fg_color=$(get_tmux_option "@cpu_temp_high_fg_color" "$cpu_temp_high_default_fg_color")
|
||||
}
|
||||
|
||||
print_fg_color() {
|
||||
local cpu_temp
|
||||
local cpu_temp_status
|
||||
cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||
cpu_temp_status=$(temp_status "$cpu_temp")
|
||||
if [ "$cpu_temp_status" == "low" ]; then
|
||||
echo "$cpu_temp_low_fg_color"
|
||||
elif [ "$cpu_temp_status" == "medium" ]; then
|
||||
echo "$cpu_temp_medium_fg_color"
|
||||
elif [ "$cpu_temp_status" == "high" ]; then
|
||||
echo "$cpu_temp_high_fg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_fg_color_settings
|
||||
print_fg_color
|
||||
}
|
||||
main
|
||||
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp_icon.sh
Executable file
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/cpu_temp_icon.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
cpu_temp_low_icon=""
|
||||
cpu_temp_medium_icon=""
|
||||
cpu_temp_high_icon=""
|
||||
|
||||
cpu_temp_low_default_icon="="
|
||||
cpu_temp_medium_default_icon="≡"
|
||||
cpu_temp_high_default_icon="≣"
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_settings() {
|
||||
cpu_temp_low_icon=$(get_tmux_option "@cpu_temp_low_icon" "$cpu_temp_low_default_icon")
|
||||
cpu_temp_medium_icon=$(get_tmux_option "@cpu_temp_medium_icon" "$cpu_temp_medium_default_icon")
|
||||
cpu_temp_high_icon=$(get_tmux_option "@cpu_temp_high_icon" "$cpu_temp_high_default_icon")
|
||||
}
|
||||
|
||||
print_icon() {
|
||||
local cpu_temp
|
||||
local cpu_temp_status
|
||||
cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||
cpu_temp_status=$(temp_status "$cpu_temp")
|
||||
if [ "$cpu_temp_status" == "low" ]; then
|
||||
echo "$cpu_temp_low_icon"
|
||||
elif [ "$cpu_temp_status" == "medium" ]; then
|
||||
echo "$cpu_temp_medium_icon"
|
||||
elif [ "$cpu_temp_status" == "high" ]; then
|
||||
echo "$cpu_temp_high_icon"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_settings
|
||||
print_icon "$1"
|
||||
}
|
||||
main "$@"
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_bg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_bg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gpu_low_bg_color=""
|
||||
gpu_medium_bg_color=""
|
||||
gpu_high_bg_color=""
|
||||
|
||||
gpu_low_default_bg_color="#[bg=green]"
|
||||
gpu_medium_default_bg_color="#[bg=yellow]"
|
||||
gpu_high_default_bg_color="#[bg=red]"
|
||||
|
||||
get_bg_color_settings() {
|
||||
gpu_low_bg_color=$(get_tmux_option "@gpu_low_bg_color" "$gpu_low_default_bg_color")
|
||||
gpu_medium_bg_color=$(get_tmux_option "@gpu_medium_bg_color" "$gpu_medium_default_bg_color")
|
||||
gpu_high_bg_color=$(get_tmux_option "@gpu_high_bg_color" "$gpu_high_default_bg_color")
|
||||
}
|
||||
|
||||
print_bg_color() {
|
||||
local gpu_percentage
|
||||
local gpu_load_status
|
||||
gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//')
|
||||
gpu_load_status=$(load_status "$gpu_percentage" "gpu")
|
||||
if [ "$gpu_load_status" == "low" ]; then
|
||||
echo "$gpu_low_bg_color"
|
||||
elif [ "$gpu_load_status" == "medium" ]; then
|
||||
echo "$gpu_medium_bg_color"
|
||||
elif [ "$gpu_load_status" == "high" ]; then
|
||||
echo "$gpu_high_bg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_bg_color_settings
|
||||
print_bg_color
|
||||
}
|
||||
main "$@"
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_fg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_fg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gpu_low_fg_color=""
|
||||
gpu_medium_fg_color=""
|
||||
gpu_high_fg_color=""
|
||||
|
||||
gpu_low_default_fg_color="#[fg=green]"
|
||||
gpu_medium_default_fg_color="#[fg=yellow]"
|
||||
gpu_high_default_fg_color="#[fg=red]"
|
||||
|
||||
get_fg_color_settings() {
|
||||
gpu_low_fg_color=$(get_tmux_option "@gpu_low_fg_color" "$gpu_low_default_fg_color")
|
||||
gpu_medium_fg_color=$(get_tmux_option "@gpu_medium_fg_color" "$gpu_medium_default_fg_color")
|
||||
gpu_high_fg_color=$(get_tmux_option "@gpu_high_fg_color" "$gpu_high_default_fg_color")
|
||||
}
|
||||
|
||||
print_fg_color() {
|
||||
local gpu_percentage
|
||||
local gpu_load_status
|
||||
gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//')
|
||||
gpu_load_status=$(load_status "$gpu_percentage" "gpu")
|
||||
if [ "$gpu_load_status" == "low" ]; then
|
||||
echo "$gpu_low_fg_color"
|
||||
elif [ "$gpu_load_status" == "medium" ]; then
|
||||
echo "$gpu_medium_fg_color"
|
||||
elif [ "$gpu_load_status" == "high" ]; then
|
||||
echo "$gpu_high_fg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_fg_color_settings
|
||||
print_fg_color
|
||||
}
|
||||
main "$@"
|
||||
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_icon.sh
Executable file
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_icon.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
gpu_low_icon=""
|
||||
gpu_medium_icon=""
|
||||
gpu_high_icon=""
|
||||
|
||||
gpu_low_default_icon="="
|
||||
gpu_medium_default_icon="≡"
|
||||
gpu_high_default_icon="≣"
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_settings() {
|
||||
gpu_low_icon=$(get_tmux_option "@gpu_low_icon" "$gpu_low_default_icon")
|
||||
gpu_medium_icon=$(get_tmux_option "@gpu_medium_icon" "$gpu_medium_default_icon")
|
||||
gpu_high_icon=$(get_tmux_option "@gpu_high_icon" "$gpu_high_default_icon")
|
||||
}
|
||||
|
||||
print_icon() {
|
||||
local gpu_percentage
|
||||
local gpu_load_status
|
||||
gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//')
|
||||
gpu_load_status=$(load_status "$gpu_percentage" "gpu")
|
||||
if [ "$gpu_load_status" == "low" ]; then
|
||||
echo "$gpu_low_icon"
|
||||
elif [ "$gpu_load_status" == "medium" ]; then
|
||||
echo "$gpu_medium_icon"
|
||||
elif [ "$gpu_load_status" == "high" ]; then
|
||||
echo "$gpu_high_icon"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_settings
|
||||
print_icon "$1"
|
||||
}
|
||||
main "$@"
|
||||
27
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_percentage.sh
Executable file
27
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_percentage.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gpu_percentage_format="%3.1f%%"
|
||||
|
||||
print_gpu_percentage() {
|
||||
gpu_percentage_format=$(get_tmux_option "@gpu_percentage_format" "$gpu_percentage_format")
|
||||
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(cached_eval nvidia-smi)
|
||||
elif command_exists "cuda-smi"; then
|
||||
loads=$(cached_eval cuda-smi)
|
||||
else
|
||||
echo "No GPU"
|
||||
return
|
||||
fi
|
||||
echo "$loads" | sed -nr 's/.*\s([0-9]+)%.*/\1/p' | awk -v format="$gpu_percentage_format" '{sum+=$1; n+=1} END {printf format, sum/n}'
|
||||
}
|
||||
|
||||
main() {
|
||||
print_gpu_percentage
|
||||
}
|
||||
main
|
||||
34
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp.sh
Executable file
34
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gpu_temp_format="%2.0f"
|
||||
gpu_temp_unit="C"
|
||||
|
||||
print_gpu_temp() {
|
||||
gpu_temp_format=$(get_tmux_option "@gpu_temp_format" "$gpu_temp_format")
|
||||
gpu_temp_unit=$(get_tmux_option "@gpu_temp_unit" "$gpu_temp_unit")
|
||||
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(cached_eval nvidia-smi)
|
||||
elif command_exists "cuda-smi"; then
|
||||
loads=$(cached_eval cuda-smi)
|
||||
else
|
||||
echo "No GPU"
|
||||
return
|
||||
fi
|
||||
tempC=$(echo "$loads" | sed -nr 's/.*\s([0-9]+)C.*/\1/p' | awk '{sum+=$1; n+=1} END {printf "%5.3f", sum/n}')
|
||||
if [ "$gpu_temp_unit" == "C" ]; then
|
||||
echo "$tempC" | awk -v format="${gpu_temp_format}C" '{sum+=$1} END {printf format, sum}'
|
||||
else
|
||||
echo "$tempC" | awk -v format="${gpu_temp_format}F" '{sum+=$1} END {printf format, sum*9/5+32}'
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
print_gpu_temp
|
||||
}
|
||||
main "$@"
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp_bg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp_bg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gpu_temp_low_bg_color=""
|
||||
gpu_temp_medium_bg_color=""
|
||||
gpu_temp_high_bg_color=""
|
||||
|
||||
gpu_temp_low_default_bg_color="#[bg=green]"
|
||||
gpu_temp_medium_default_bg_color="#[bg=yellow]"
|
||||
gpu_temp_high_default_bg_color="#[bg=red]"
|
||||
|
||||
get_bg_color_settings() {
|
||||
gpu_temp_low_bg_color=$(get_tmux_option "@gpu_temp_low_bg_color" "$gpu_temp_low_default_bg_color")
|
||||
gpu_temp_medium_bg_color=$(get_tmux_option "@gpu_temp_medium_bg_color" "$gpu_temp_medium_default_bg_color")
|
||||
gpu_temp_high_bg_color=$(get_tmux_option "@gpu_temp_high_bg_color" "$gpu_temp_high_default_bg_color")
|
||||
}
|
||||
|
||||
print_bg_color() {
|
||||
local gpu_temp
|
||||
local gpu_temp_status
|
||||
gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||
gpu_temp_status=$(temp_status "$gpu_temp")
|
||||
if [ "$gpu_temp_status" == "low" ]; then
|
||||
echo "$gpu_temp_low_bg_color"
|
||||
elif [ "$gpu_temp_status" == "medium" ]; then
|
||||
echo "$gpu_temp_medium_bg_color"
|
||||
elif [ "$gpu_temp_status" == "high" ]; then
|
||||
echo "$gpu_temp_high_bg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_bg_color_settings
|
||||
print_bg_color
|
||||
}
|
||||
main "$@"
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp_fg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp_fg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gpu_temp_low_fg_color=""
|
||||
gpu_temp_medium_fg_color=""
|
||||
gpu_temp_high_fg_color=""
|
||||
|
||||
gpu_temp_low_default_fg_color="#[fg=green]"
|
||||
gpu_temp_medium_default_fg_color="#[fg=yellow]"
|
||||
gpu_temp_high_default_fg_color="#[fg=red]"
|
||||
|
||||
get_fg_color_settings() {
|
||||
gpu_temp_low_fg_color=$(get_tmux_option "@gpu_temp_low_fg_color" "$gpu_temp_low_default_fg_color")
|
||||
gpu_temp_medium_fg_color=$(get_tmux_option "@gpu_temp_medium_fg_color" "$gpu_temp_medium_default_fg_color")
|
||||
gpu_temp_high_fg_color=$(get_tmux_option "@gpu_temp_high_fg_color" "$gpu_temp_high_default_fg_color")
|
||||
}
|
||||
|
||||
print_fg_color() {
|
||||
local gpu_temp
|
||||
local gpu_temp_status
|
||||
gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||
gpu_temp_status=$(temp_status "$gpu_temp")
|
||||
if [ "$gpu_temp_status" == "low" ]; then
|
||||
echo "$gpu_temp_low_fg_color"
|
||||
elif [ "$gpu_temp_status" == "medium" ]; then
|
||||
echo "$gpu_temp_medium_fg_color"
|
||||
elif [ "$gpu_temp_status" == "high" ]; then
|
||||
echo "$gpu_temp_high_fg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_fg_color_settings
|
||||
print_fg_color
|
||||
}
|
||||
main "$@"
|
||||
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp_icon.sh
Executable file
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/gpu_temp_icon.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
gpu_temp_low_icon=""
|
||||
gpu_temp_medium_icon=""
|
||||
gpu_temp_high_icon=""
|
||||
|
||||
gpu_temp_low_default_icon="="
|
||||
gpu_temp_medium_default_icon="≡"
|
||||
gpu_temp_high_default_icon="≣"
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_settings() {
|
||||
gpu_temp_low_icon=$(get_tmux_option "@gpu_temp_low_icon" "$gpu_temp_low_default_icon")
|
||||
gpu_temp_medium_icon=$(get_tmux_option "@gpu_temp_medium_icon" "$gpu_temp_medium_default_icon")
|
||||
gpu_temp_high_icon=$(get_tmux_option "@gpu_temp_high_icon" "$gpu_temp_high_default_icon")
|
||||
}
|
||||
|
||||
print_icon() {
|
||||
local gpu_temp
|
||||
local gpu_temp_status
|
||||
gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||
gpu_temp_status=$(temp_status "$gpu_temp")
|
||||
if [ "$gpu_temp_status" == "low" ]; then
|
||||
echo "$gpu_temp_low_icon"
|
||||
elif [ "$gpu_temp_status" == "medium" ]; then
|
||||
echo "$gpu_temp_medium_icon"
|
||||
elif [ "$gpu_temp_status" == "high" ]; then
|
||||
echo "$gpu_temp_high_icon"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_settings
|
||||
print_icon "$1"
|
||||
}
|
||||
main "$@"
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_bg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_bg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gram_low_bg_color=""
|
||||
gram_medium_bg_color=""
|
||||
gram_high_bg_color=""
|
||||
|
||||
gram_low_default_bg_color="#[bg=green]"
|
||||
gram_medium_default_bg_color="#[bg=yellow]"
|
||||
gram_high_default_bg_color="#[bg=red]"
|
||||
|
||||
get_bg_color_settings() {
|
||||
gram_low_bg_color=$(get_tmux_option "@gram_low_bg_color" "$gram_low_default_bg_color")
|
||||
gram_medium_bg_color=$(get_tmux_option "@gram_medium_bg_color" "$gram_medium_default_bg_color")
|
||||
gram_high_bg_color=$(get_tmux_option "@gram_high_bg_color" "$gram_high_default_bg_color")
|
||||
}
|
||||
|
||||
print_bg_color() {
|
||||
local gram_percentage
|
||||
local gram_load_status
|
||||
gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//')
|
||||
gram_load_status=$(load_status "$gram_percentage" "gram")
|
||||
if [ "$gram_load_status" == "low" ]; then
|
||||
echo "$gram_low_bg_color"
|
||||
elif [ "$gram_load_status" == "medium" ]; then
|
||||
echo "$gram_medium_bg_color"
|
||||
elif [ "$gram_load_status" == "high" ]; then
|
||||
echo "$gram_high_bg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_bg_color_settings
|
||||
print_bg_color
|
||||
}
|
||||
main "$@"
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_fg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_fg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gram_low_fg_color=""
|
||||
gram_medium_fg_color=""
|
||||
gram_high_fg_color=""
|
||||
|
||||
gram_low_default_fg_color="#[fg=green]"
|
||||
gram_medium_default_fg_color="#[fg=yellow]"
|
||||
gram_high_default_fg_color="#[fg=red]"
|
||||
|
||||
get_fg_color_settings() {
|
||||
gram_low_fg_color=$(get_tmux_option "@gram_low_fg_color" "$gram_low_default_fg_color")
|
||||
gram_medium_fg_color=$(get_tmux_option "@gram_medium_fg_color" "$gram_medium_default_fg_color")
|
||||
gram_high_fg_color=$(get_tmux_option "@gram_high_fg_color" "$gram_high_default_fg_color")
|
||||
}
|
||||
|
||||
print_fg_color() {
|
||||
local gram_percentage
|
||||
local gram_load_status
|
||||
gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//')
|
||||
gram_load_status=$(load_status "$gram_percentage" "gram")
|
||||
if [ "$gram_load_status" == "low" ]; then
|
||||
echo "$gram_low_fg_color"
|
||||
elif [ "$gram_load_status" == "medium" ]; then
|
||||
echo "$gram_medium_fg_color"
|
||||
elif [ "$gram_load_status" == "high" ]; then
|
||||
echo "$gram_high_fg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_fg_color_settings
|
||||
print_fg_color
|
||||
}
|
||||
main "$@"
|
||||
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_icon.sh
Executable file
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_icon.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
gram_low_icon=""
|
||||
gram_medium_icon=""
|
||||
gram_high_icon=""
|
||||
|
||||
gram_low_default_icon="="
|
||||
gram_medium_default_icon="≡"
|
||||
gram_high_default_icon="≣"
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_settings() {
|
||||
gram_low_icon=$(get_tmux_option "@gram_low_icon" "$gram_low_default_icon")
|
||||
gram_medium_icon=$(get_tmux_option "@gram_medium_icon" "$gram_medium_default_icon")
|
||||
gram_high_icon=$(get_tmux_option "@gram_high_icon" "$gram_high_default_icon")
|
||||
}
|
||||
|
||||
print_icon() {
|
||||
local gram_percentage
|
||||
local gram_load_status
|
||||
gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//')
|
||||
gram_load_status=$(load_status "$gram_percentage" "gram")
|
||||
if [ "$gram_load_status" == "low" ]; then
|
||||
echo "$gram_low_icon"
|
||||
elif [ "$gram_load_status" == "medium" ]; then
|
||||
echo "$gram_medium_icon"
|
||||
elif [ "$gram_load_status" == "high" ]; then
|
||||
echo "$gram_high_icon"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_settings
|
||||
print_icon "$1"
|
||||
}
|
||||
main "$@"
|
||||
27
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_percentage.sh
Executable file
27
config-files/.config/tmux/plugins/tmux-cpu/scripts/gram_percentage.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
gram_percentage_format="%3.1f%%"
|
||||
|
||||
print_gram_percentage() {
|
||||
gram_percentage_format=$(get_tmux_option "@gram_percentage_format" "$gram_percentage_format")
|
||||
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(cached_eval nvidia-smi | sed -nr 's/.*\s([0-9]+)MiB\s*\/\s*([0-9]+)MiB.*/\1 \2/p')
|
||||
elif command_exists "cuda-smi"; then
|
||||
loads=$(cached_eval cuda-smi | sed -nr 's/.*\s([0-9.]+) of ([0-9.]+) MB.*/\1 \2/p' | awk '{print $2-$1" "$2}')
|
||||
else
|
||||
echo "No GPU"
|
||||
return
|
||||
fi
|
||||
echo "$loads" | awk -v format="$gram_percentage_format" '{used+=$1; tot+=$2} END {printf format, 100*used/tot}'
|
||||
}
|
||||
|
||||
main() {
|
||||
print_gram_percentage
|
||||
}
|
||||
main "$@"
|
||||
152
config-files/.config/tmux/plugins/tmux-cpu/scripts/helpers.sh
Normal file
152
config-files/.config/tmux/plugins/tmux-cpu/scripts/helpers.sh
Normal file
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
|
||||
get_tmux_option() {
|
||||
local option
|
||||
local default_value
|
||||
local option_value
|
||||
option="$1"
|
||||
default_value="$2"
|
||||
option_value="$(tmux show-option -qv "$option")"
|
||||
if [ -z "$option_value" ]; then
|
||||
option_value="$(tmux show-option -gqv "$option")"
|
||||
fi
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
echo "$option_value"
|
||||
fi
|
||||
}
|
||||
|
||||
is_osx() {
|
||||
[ "$(uname)" == "Darwin" ]
|
||||
}
|
||||
|
||||
is_freebsd() {
|
||||
[ "$(uname)" == "FreeBSD" ]
|
||||
}
|
||||
|
||||
is_openbsd() {
|
||||
[ "$(uname)" == "OpenBSD" ]
|
||||
}
|
||||
|
||||
is_linux() {
|
||||
[ "$(uname)" == "Linux" ]
|
||||
}
|
||||
|
||||
is_cygwin() {
|
||||
command -v WMIC &>/dev/null
|
||||
}
|
||||
|
||||
is_linux_iostat() {
|
||||
# Bug in early versions of linux iostat -V return error code
|
||||
iostat -c &>/dev/null
|
||||
}
|
||||
|
||||
# is second float bigger or equal?
|
||||
fcomp() {
|
||||
awk -v n1="$1" -v n2="$2" 'BEGIN {if (n1<=n2) exit 0; exit 1}'
|
||||
}
|
||||
|
||||
load_status() {
|
||||
local percentage=$1
|
||||
local prefix=$2
|
||||
medium_thresh=$(get_tmux_option "@${prefix}_medium_thresh" "30")
|
||||
high_thresh=$(get_tmux_option "@${prefix}_high_thresh" "80")
|
||||
if fcomp "$high_thresh" "$percentage"; then
|
||||
echo "high"
|
||||
elif fcomp "$medium_thresh" "$percentage" && fcomp "$percentage" "$high_thresh"; then
|
||||
echo "medium"
|
||||
else
|
||||
echo "low"
|
||||
fi
|
||||
}
|
||||
|
||||
temp_status() {
|
||||
local temp
|
||||
temp=$1
|
||||
cpu_temp_medium_thresh=$(get_tmux_option "@cpu_temp_medium_thresh" "80")
|
||||
cpu_temp_high_thresh=$(get_tmux_option "@cpu_temp_high_thresh" "90")
|
||||
if fcomp "$cpu_temp_high_thresh" "$temp"; then
|
||||
echo "high"
|
||||
elif fcomp "$cpu_temp_medium_thresh" "$temp" && fcomp "$temp" "$cpu_temp_high_thresh"; then
|
||||
echo "medium"
|
||||
else
|
||||
echo "low"
|
||||
fi
|
||||
}
|
||||
|
||||
cpus_number() {
|
||||
if is_linux; then
|
||||
if command_exists "nproc"; then
|
||||
nproc
|
||||
else
|
||||
echo "$(($(sed -n 's/^processor.*:\s*\([0-9]\+\)/\1/p' /proc/cpuinfo | tail -n 1) + 1))"
|
||||
fi
|
||||
else
|
||||
sysctl -n hw.ncpu
|
||||
fi
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
local command
|
||||
command="$1"
|
||||
command -v "$command" &>/dev/null
|
||||
}
|
||||
|
||||
get_tmp_dir() {
|
||||
local tmpdir
|
||||
tmpdir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
|
||||
[ -d "$tmpdir" ] || local tmpdir=~/tmp
|
||||
echo "$tmpdir/tmux-$EUID-cpu"
|
||||
}
|
||||
|
||||
get_time() {
|
||||
date +%s.%N
|
||||
}
|
||||
|
||||
get_cache_val() {
|
||||
local key
|
||||
local timeout
|
||||
local cache
|
||||
key="$1"
|
||||
# seconds after which cache is invalidated
|
||||
timeout="${2:-2}"
|
||||
cache="$(get_tmp_dir)/$key"
|
||||
if [ -f "$cache" ]; then
|
||||
awk -v cache="$(head -n1 "$cache")" -v timeout="$timeout" -v now="$(get_time)" \
|
||||
'BEGIN {if (now - timeout < cache) exit 0; exit 1}' &&
|
||||
tail -n+2 "$cache"
|
||||
fi
|
||||
}
|
||||
|
||||
put_cache_val() {
|
||||
local key
|
||||
local val
|
||||
local tmpdir
|
||||
key="$1"
|
||||
val="${*:2}"
|
||||
tmpdir="$(get_tmp_dir)"
|
||||
[ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir"
|
||||
(
|
||||
get_time
|
||||
echo -n "$val"
|
||||
) >"$tmpdir/$key"
|
||||
echo -n "$val"
|
||||
}
|
||||
|
||||
cached_eval() {
|
||||
local command
|
||||
local key
|
||||
local val
|
||||
command="$1"
|
||||
key="$(basename "$command")"
|
||||
val="$(get_cache_val "$key")"
|
||||
if [ -z "$val" ]; then
|
||||
put_cache_val "$key" "$($command "${@:2}")"
|
||||
else
|
||||
echo -n "$val"
|
||||
fi
|
||||
}
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_bg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_bg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
ram_low_bg_color=""
|
||||
ram_medium_bg_color=""
|
||||
ram_high_bg_color=""
|
||||
|
||||
ram_low_default_bg_color="#[bg=green]"
|
||||
ram_medium_default_bg_color="#[bg=yellow]"
|
||||
ram_high_default_bg_color="#[bg=red]"
|
||||
|
||||
get_bg_color_settings() {
|
||||
ram_low_bg_color=$(get_tmux_option "@ram_low_bg_color" "$ram_low_default_bg_color")
|
||||
ram_medium_bg_color=$(get_tmux_option "@ram_medium_bg_color" "$ram_medium_default_bg_color")
|
||||
ram_high_bg_color=$(get_tmux_option "@ram_high_bg_color" "$ram_high_default_bg_color")
|
||||
}
|
||||
|
||||
print_bg_color() {
|
||||
local ram_percentage
|
||||
local ram_load_status
|
||||
ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//')
|
||||
ram_load_status=$(load_status "$ram_percentage" "ram")
|
||||
if [ "$ram_load_status" == "low" ]; then
|
||||
echo "$ram_low_bg_color"
|
||||
elif [ "$ram_load_status" == "medium" ]; then
|
||||
echo "$ram_medium_bg_color"
|
||||
elif [ "$ram_load_status" == "high" ]; then
|
||||
echo "$ram_high_bg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_bg_color_settings
|
||||
print_bg_color
|
||||
}
|
||||
main
|
||||
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_fg_color.sh
Executable file
40
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_fg_color.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
ram_low_fg_color=""
|
||||
ram_medium_fg_color=""
|
||||
ram_high_fg_color=""
|
||||
|
||||
ram_low_default_fg_color="#[fg=green]"
|
||||
ram_medium_default_fg_color="#[fg=yellow]"
|
||||
ram_high_default_fg_color="#[fg=red]"
|
||||
|
||||
get_fg_color_settings() {
|
||||
ram_low_fg_color=$(get_tmux_option "@ram_low_fg_color" "$ram_low_default_fg_color")
|
||||
ram_medium_fg_color=$(get_tmux_option "@ram_medium_fg_color" "$ram_medium_default_fg_color")
|
||||
ram_high_fg_color=$(get_tmux_option "@ram_high_fg_color" "$ram_high_default_fg_color")
|
||||
}
|
||||
|
||||
print_fg_color() {
|
||||
local ram_percentage
|
||||
local ram_load_status
|
||||
ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//')
|
||||
ram_load_status=$(load_status "$ram_percentage" "ram")
|
||||
if [ "$ram_load_status" == "low" ]; then
|
||||
echo "$ram_low_fg_color"
|
||||
elif [ "$ram_load_status" == "medium" ]; then
|
||||
echo "$ram_medium_fg_color"
|
||||
elif [ "$ram_load_status" == "high" ]; then
|
||||
echo "$ram_high_fg_color"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_fg_color_settings
|
||||
print_fg_color
|
||||
}
|
||||
main
|
||||
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_icon.sh
Executable file
42
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_icon.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
# script global variables
|
||||
ram_low_icon=""
|
||||
ram_medium_icon=""
|
||||
ram_high_icon=""
|
||||
|
||||
ram_low_default_icon="="
|
||||
ram_medium_default_icon="≡"
|
||||
ram_high_default_icon="≣"
|
||||
|
||||
# icons are set as script global variables
|
||||
get_icon_settings() {
|
||||
ram_low_icon=$(get_tmux_option "@ram_low_icon" "$ram_low_default_icon")
|
||||
ram_medium_icon=$(get_tmux_option "@ram_medium_icon" "$ram_medium_default_icon")
|
||||
ram_high_icon=$(get_tmux_option "@ram_high_icon" "$ram_high_default_icon")
|
||||
}
|
||||
|
||||
print_icon() {
|
||||
local ram_percentage
|
||||
local ram_load_status
|
||||
ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//')
|
||||
ram_load_status=$(load_status "$ram_percentage" "ram")
|
||||
if [ "$ram_load_status" == "low" ]; then
|
||||
echo "$ram_low_icon"
|
||||
elif [ "$ram_load_status" == "medium" ]; then
|
||||
echo "$ram_medium_icon"
|
||||
elif [ "$ram_load_status" == "high" ]; then
|
||||
echo "$ram_high_icon"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
get_icon_settings
|
||||
print_icon "$1"
|
||||
}
|
||||
main "$@"
|
||||
52
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_percentage.sh
Executable file
52
config-files/.config/tmux/plugins/tmux-cpu/scripts/ram_percentage.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck source=scripts/helpers.sh
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
ram_percentage_format="%3.1f%%"
|
||||
|
||||
sum_macos_vm_stats() {
|
||||
grep -Eo '[0-9]+' |
|
||||
awk '{ a += $1 * 4096 } END { print a }'
|
||||
}
|
||||
|
||||
print_ram_percentage() {
|
||||
ram_percentage_format=$(get_tmux_option "@ram_percentage_format" "$ram_percentage_format")
|
||||
|
||||
if command_exists "free"; then
|
||||
cached_eval free | awk -v format="$ram_percentage_format" '$1 ~ /Mem/ {printf(format, 100*$3/$2)}'
|
||||
elif command_exists "vm_stat"; then
|
||||
# page size of 4096 bytes
|
||||
stats="$(cached_eval vm_stat)"
|
||||
|
||||
used_and_cached=$(
|
||||
echo "$stats" |
|
||||
grep -E "(Pages active|Pages inactive|Pages speculative|Pages wired down|Pages occupied by compressor)" |
|
||||
sum_macos_vm_stats
|
||||
)
|
||||
|
||||
cached=$(
|
||||
echo "$stats" |
|
||||
grep -E "(Pages purgeable|File-backed pages)" |
|
||||
sum_macos_vm_stats
|
||||
)
|
||||
|
||||
free=$(
|
||||
echo "$stats" |
|
||||
grep -E "(Pages free)" |
|
||||
sum_macos_vm_stats
|
||||
)
|
||||
|
||||
used=$((used_and_cached - cached))
|
||||
total=$((used_and_cached + free))
|
||||
|
||||
echo "$used $total" | awk -v format="$ram_percentage_format" '{printf(format, 100*$1/$2)}'
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
print_ram_percentage
|
||||
}
|
||||
main
|
||||
78
config-files/.config/tmux/tmux.conf
Normal file
78
config-files/.config/tmux/tmux.conf
Normal file
@@ -0,0 +1,78 @@
|
||||
# easy reload config
|
||||
bind-key r source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded."
|
||||
|
||||
# Enable full colors
|
||||
set-option -sa terminal-overrides ",xterm*:Tc"
|
||||
|
||||
# set window split
|
||||
bind-key v split-window -h -c "#{pane_current_path}"
|
||||
bind-key b split-window -v -c "#{pane_current_path}"
|
||||
|
||||
# Leader Key (using C-s instead of the default C-b)
|
||||
set -g prefix C-s
|
||||
bind-key C-s last-window
|
||||
|
||||
# Start index at 1
|
||||
set -g base-index 1
|
||||
set -g pane-base-index 1
|
||||
set-window-option -g pane-base-index 1
|
||||
set-option -g renumber-windows on
|
||||
|
||||
# Allows for faster key repetition
|
||||
set -s escape-time 50
|
||||
|
||||
# Rather than constraining window size to the maximum size of any client
|
||||
# connected to the *session*, constrain window size to the maximum size of any
|
||||
# client connected to *that window*. Much more reasonable.
|
||||
setw -g aggressive-resize on
|
||||
|
||||
# hjkl pane traversal
|
||||
bind-key h select-pane -L
|
||||
bind-key j select-pane -D
|
||||
bind-key k select-pane -U
|
||||
bind-key l select-pane -R
|
||||
|
||||
bind-key C command-prompt -p "Name of new window: " "new-window -n '%%'"
|
||||
|
||||
# auto window rename
|
||||
set-window-option -g automatic-rename
|
||||
|
||||
# Vi copypaste mode
|
||||
set-window-option -g mode-keys vi
|
||||
bind g copy-mode
|
||||
bind -T copy-mode-vi v send -X begin-selection
|
||||
bind-key -T copy-mode-vi y send -X copy-selection-and-cancel
|
||||
bind P paste-buffer
|
||||
|
||||
# Mouse support
|
||||
set -g mouse on
|
||||
|
||||
# VIM Options
|
||||
set-option -g focus-events on
|
||||
set-option -sa terminal-features ',foot:RGB'
|
||||
|
||||
# Remove confirm prompt when closing pane
|
||||
bind-key x kill-pane
|
||||
|
||||
# Load TMUX Plugins
|
||||
set -g @catppuccin_window_left_separator ""
|
||||
set -g @catppuccin_window_right_separator " "
|
||||
set -g @catppuccin_window_middle_separator " █"
|
||||
set -g @catppuccin_window_number_position "right"
|
||||
|
||||
set -g @catppuccin_window_default_fill "number"
|
||||
set -g @catppuccin_window_default_text "#W"
|
||||
|
||||
set -g @catppuccin_window_current_fill "number"
|
||||
set -g @catppuccin_window_current_text "#W"
|
||||
|
||||
set -g @catppuccin_status_modules_right "directory user host session cpu battery"
|
||||
set -g @catppuccin_status_left_separator " "
|
||||
set -g @catppuccin_status_right_separator ""
|
||||
set -g @catppuccin_status_fill "icon"
|
||||
set -g @catppuccin_status_connect_separator "no"
|
||||
|
||||
set -g @catppuccin_directory_text "#{pane_current_path}"
|
||||
run '~/.config/tmux/plugins/theme/theme.tmux'
|
||||
run-shell '~/.config/tmux/plugins/tmux-cpu/cpu.tmux'
|
||||
run-shell '~/.config/tmux/plugins/tmux-battery/battery.tmux'
|
||||
Reference in New Issue
Block a user