Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cpu): add cpu module #89

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
4. [Status](#status)
5. [Customizing modules](#customizing-modules)
6. [Battery module](#battery-module)
7. [CPU module](#CPU-module)
5. [Create a custom module](#create-a-custom-module)
6. [Configuration Examples](#configuration-examples)
1. [Config 1](#config-1)
Expand Down Expand Up @@ -277,6 +278,27 @@ Add the battery module to the status modules list.
set -g @catppuccin_status_modules_right "... battery ..."
```

### CPU module

#### Requirements
This module depends on [tmux-cpu](https://github.com/tmux-plugins/tmux-cpu/tree/master).

#### Install
The prefered way to install tmux-cpu is using [TPM](https://github.com/tmux-plugins/tpm).

#### Configure
Load tmux-cpu after you load catppuccin.
```sh
set -g @plugin 'catppuccin/tmux'
...
set -g @plugin 'tmux-plugins/tmux-cpu'
```

Add the cpu module to the status modules list.
```sh
set -g @catppuccin_status_modules_right "... cpu ..."
```

## Create a custom module

It is possible to add a new custom module or overrite any of the existing modules.
Expand Down
14 changes: 14 additions & 0 deletions status/cpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
show_cpu() {
tmux set-option -g @cpu_low_bg_color "$thm_yellow" # background color when cpu is low
tmux set-option -g @cpu_medium_bg_color "$thm_orange" # background color when cpu is medium
tmux set-option -g @cpu_high_bg_color "$thm_red" # background color when cpu is high

local index=$1
local icon=$(get_tmux_option "@catppuccin_cpu_icon" "")
local color="$(get_tmux_option "@catppuccin_cpu_color" "#{cpu_bg_color}")"
local text="$(get_tmux_option "@catppuccin_cpu_text" "#{cpu_percentage}")"

local module=$( build_status_module "$index" "$icon" "$color" "$text" )

echo "$module"
}