Merge pull request #143 from adrianmihalko/master

Add load average support
This commit is contained in:
Ethan Edwards 2021-12-22 17:47:40 -05:00 committed by GitHub
commit 257bc1f199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 6 deletions

View file

@ -119,6 +119,15 @@ Customize label
set -g @dracula-cpu-usage-label "CPU"
```
Show system load average instead of CPU usage percentage (default)
```bash
set -g @dracula-cpu-display-load true
```
CPU usage percentage (default) - in percentage (output: %)
Load average is the average system load calculated over a given period of time of 1, 5 and 15 minutes (output: x.x x.x x.x)
#### gpu-usage options
Customize label

View file

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

View file

@ -27,13 +27,30 @@ get_percent()
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
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
cpu_percent=$(get_percent)
echo "$cpu_label $cpu_percent"
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_percent=$(get_percent)
echo "$cpu_label $cpu_percent"
fi
sleep $RATE
}