Add load average support

This commit is contained in:
adrianmihalko 2021-12-22 23:11:09 +01:00
parent b06419366c
commit 2dbd75cadf
3 changed files with 29 additions and 6 deletions

View file

@ -119,6 +119,12 @@ Customize label
set -g @dracula-cpu-usage-label "CPU" set -g @dracula-cpu-usage-label "CPU"
``` ```
Show load average instead of percentage
```bash
set -g @dracula-cpu-display-load true
```
#### gpu-usage options #### gpu-usage options
Customize label Customize label

View file

@ -21,7 +21,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
* Git branch and status * Git branch and status
* Battery percentage and AC power connection status * Battery percentage and AC power connection status
* Refresh rate control * Refresh rate control
* CPU usage * CPU usage (percentage or load average)
* RAM usage * RAM usage
* GPU usage * GPU usage
* Color code based on if prefix is active or not * Color code based on if prefix is active or not

View file

@ -27,13 +27,30 @@ get_percent()
esac esac
} }
main() get_load() {
{ case $(uname -s) in
Linux | Darwin)
loadavg=$(uptime | awk -F'[a-z]:' '{ print $2}' | sed 's/,//g')
echo $loadavg
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*)
# TODO - windows compatability
;;
esac
}
main() {
# storing the refresh rate in the variable RATE, default is 5 # storing the refresh rate in the variable RATE, default is 5
RATE=$(get_tmux_option "@dracula-refresh-rate" 5) RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
cpu_load=$(get_tmux_option "@dracula-cpu-display-load" false)
if [ "$cpu_load" = true ]; then
echo "$(get_load)"
else
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU") cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
cpu_percent=$(get_percent) cpu_percent=$(get_percent)
echo "$cpu_label $cpu_percent" echo "$cpu_label $cpu_percent"
fi
sleep $RATE sleep $RATE
} }