Populate repo

This commit is contained in:
Christian Nieves
2022-04-19 15:50:47 +00:00
commit 76a6480b62
1200 changed files with 108582 additions and 0 deletions

View File

@ -0,0 +1,16 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
# 2 space indentation
[*.{sh,tmux}]
indent_style = space
indent_size = 2

View File

@ -0,0 +1,2 @@
Camille TJHOA <camille.tjhoa@outlook.com>
Yuichi Kiri <kiririmode@gmail.com>

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 ctjhoa
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,170 @@
# Tmux CPU and GPU status
Enables displaying CPU and GPU information in Tmux `status-right` and `status-left`.
Configurable percentage and icon display.
## Installation
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
Add plugin to the list of TPM plugins in `.tmux.conf`:
```shell
set -g @plugin 'tmux-plugins/tmux-cpu'
```
Hit `prefix + I` to fetch the plugin and source it.
If format strings are added to `status-right`, they should now be visible.
### Manual Installation
Clone the repo:
```shell
$ git clone https://github.com/tmux-plugins/tmux-cpu ~/clone/path
```
Add this line to the bottom of `.tmux.conf`:
```shell
run-shell ~/clone/path/cpu.tmux
```
Reload TMUX environment:
```shell
# type this in terminal
$ tmux source-file ~/.tmux.conf
```
If format strings are added to `status-right`, they should now be visible.
### Optional requirements (Linux, BSD, OSX)
- `iostat` or `sar` are the best way to get an accurate CPU percentage.
A fallback is included using `ps -aux` but could be inaccurate.
- `free` is used for obtaining system RAM status.
- `lm-sensors` is used for CPU temperature.
- `nvidia-smi` is required for GPU information.
For OSX, `cuda-smi` is required instead (but only shows GPU memory use rather than load).
If "No GPU" is displayed, it means the script was not able to find `nvidia-smi`/`cuda-smi`.
Please make sure the appropriate command is installed and in the `$PATH`.
## Usage
Add any of the supported format strings (see below) to the existing `status-right` tmux option.
Example:
```shell
# in .tmux.conf
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
```
### Supported Options
This is done by introducing 12 new format strings that can be added to
`status-right` option:
- `#{cpu_icon}` - will display a CPU status icon
- `#{cpu_percentage}` - will show CPU percentage (averaged across cores)
- `#{cpu_bg_color}` - will change the background color based on the CPU percentage
- `#{cpu_fg_color}` - will change the foreground color based on the CPU percentage
- `#{ram_icon}` - will display a RAM status icon
- `#{ram_percentage}` - will show RAM percentage (averaged across cores)
- `#{ram_bg_color}` - will change the background color based on the RAM percentage
- `#{ram_fg_color}` - will change the foreground color based on the RAM percentage
- `#{cpu_temp_icon}` - will display a CPU temperature status icon
- `#{cpu_temp}` - will show CPU temperature (averaged across cores)
- `#{cpu_temp_bg_color}` - will change the background color based on the CPU temperature
- `#{cpu_temp_fg_color}` - will change the foreground color based on the CPU temperature
GPU equivalents also exist:
- `#{gpu_icon}` - will display a GPU status icon
- `#{gpu_percentage}` - will show GPU percentage (averaged across devices)
- `#{gpu_bg_color}` - will change the background color based on the GPU percentage
- `#{gpu_fg_color}` - will change the foreground color based on the GPU percentage
- `#{gram_icon}` - will display a GPU RAM status icon
- `#{gram_percentage}` - will show GPU RAM percentage (total across devices)
- `#{gram_bg_color}` - will change the background color based on the GPU RAM percentage
- `#{gram_fg_color}` - will change the foreground color based on the GPU RAM percentage
- `#{gpu_temp_icon}` - will display a GPU temperature status icon
- `#{gpu_temp}` - will show GPU temperature (average across devices)
- `#{gpu_temp_bg_color}` - will change the background color based on the GPU temperature
- `#{gpu_temp_fg_color}` - will change the foreground color based on the GPU temperature
## Examples
CPU usage lower than 30%:<br/>
![low_fg](/screenshots/low_fg.png)
![low_bg](/screenshots/low_bg.png)
![low_icon](/screenshots/low_icon.png)
CPU usage between 30% and 80%:<br/>
![medium_fg](/screenshots/medium_fg.png)
![medium_bg](/screenshots/medium_bg.png)
![medium_icon](/screenshots/medium_icon.png)
CPU usage higher than 80%:<br/>
![high_fg](/screenshots/high_fg.png)
![high_bg](/screenshots/high_bg.png)
![high_icon](/screenshots/high_icon.png)
## Customization
Here are all available options with their default values:
```shell
@cpu_low_icon "=" # icon when cpu is low
@cpu_medium_icon "≡" # icon when cpu is medium
@cpu_high_icon "≣" # icon when cpu is high
@cpu_low_fg_color "" # foreground color when cpu is low
@cpu_medium_fg_color "" # foreground color when cpu is medium
@cpu_high_fg_color "" # foreground color when cpu is high
@cpu_low_bg_color "#[bg=green]" # background color when cpu is low
@cpu_medium_bg_color "#[bg=yellow]" # background color when cpu is medium
@cpu_high_bg_color "#[bg=red]" # background color when cpu is high
@cpu_percentage_format "%3.1f%%" # printf format to use to display percentage
@cpu_medium_thresh "30" # medium percentage threshold
@cpu_high_thresh "80" # high percentage threshold
@ram_(low_icon,high_bg_color,etc...) # same defaults as above
@cpu_temp_format "%2.0f" # printf format to use to display temperature
@cpu_temp_unit "C" # supports C & F
@cpu_temp_medium_thresh "80" # medium temperature threshold
@cpu_temp_high_thresh "90" # high temperature threshold
@cpu_temp_(low_icon,high_bg_color,etc...) # same defaults as above
```
All `@cpu_*` options are valid with `@gpu_*` (except `@cpu_*_thresh` which apply to both CPU and GPU). Additionally, `@ram_*` options become `@gram_*` for GPU equivalents.
Note that these colors depend on your terminal / X11 config.
You can can customize each one of these options in your `.tmux.conf`, for example:
```shell
set -g @cpu_low_fg_color "#[fg=#00ff00]"
set -g @cpu_percentage_format "%5.1f%%" # Add left padding
```
Don't forget to reload the tmux environment (`$ tmux source-file ~/.tmux.conf`) after you do this.
### Tmux Plugins
This plugin is part of the [tmux-plugins](https://github.com/tmux-plugins) organisation. Checkout plugins as [battery](https://github.com/tmux-plugins/tmux-battery), [logging](https://github.com/tmux-plugins/tmux-logging), [online status](https://github.com/tmux-plugins/tmux-online-status), and many more over at the [tmux-plugins](https://github.com/tmux-plugins) organisation page.
### Maintainers
- [Camille Tjhoa](https://github.com/ctjhoa)
- [Casper da Costa-Luis](https://github.com/casperdcl)
### License
[MIT](LICENSE.md)

View File

@ -0,0 +1,85 @@
#!/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=$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

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//')
local load_status=$(load_status $cpu_percentage)
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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//')
local load_status=$(load_status $cpu_percentage)
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

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//')
local load_status=$(load_status $cpu_percentage)
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

View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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]+')"
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

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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
([ "$cpu_temp_unit" == F ] && sensors -f || sensors) | 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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//')
local 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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//')
local 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

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//')
local 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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//')
local gpu_load_status=$(load_status $gpu_percentage)
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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//')
local gpu_load_status=$(load_status $gpu_percentage)
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

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//')
local gpu_load_status=$(load_status $gpu_percentage)
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

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//')
local 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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//')
local 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

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//')
local 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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//')
local gram_load_status=$(load_status $gram_percentage)
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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//')
local gram_load_status=$(load_status $gram_percentage)
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

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//')
local gram_load_status=$(load_status $gram_percentage)
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

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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*$1/$2}'
}
main() {
print_gram_percentage
}
main

View File

@ -0,0 +1,132 @@
export LANG=C
export LC_ALL=C
get_tmux_option() {
local option="$1"
local default_value="$2"
local 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
cpu_medium_thresh=$(get_tmux_option "@cpu_medium_thresh" "30")
cpu_high_thresh=$(get_tmux_option "@cpu_high_thresh" "80")
if fcomp $cpu_high_thresh $percentage; then
echo "high"
elif fcomp $cpu_medium_thresh $percentage && fcomp $percentage $cpu_high_thresh; then
echo "medium"
else
echo "low"
fi
}
temp_status() {
local 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="$1"
command -v "$command" &> /dev/null
}
get_tmp_dir() {
local 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="$1"
# seconds after which cache is invalidated
local timeout="${2:-2}"
local 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="$1"
local val="${@:2}"
local tmpdir="$(get_tmp_dir)"
[ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir"
echo "$(get_time)" > "$tmpdir/$key"
echo -n "$val" >> "$tmpdir/$key"
echo -n "$val"
}
cached_eval(){
local command="$1"
local key="$(basename "$command")"
local val="$(get_cache_val "$key")"
if [ -z "$val" ]; then
put_cache_val "$key" "$($command "${@:2}")"
else
echo -n "$val"
fi
}

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//')
local ram_load_status=$(load_status $ram_percentage)
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

View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//')
local ram_load_status=$(load_status $ram_percentage)
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

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//')
local ram_load_status=$(load_status $ram_percentage)
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

View File

@ -0,0 +1,48 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
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