1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 12:20:07 +00:00

Add CPU load threshold setting (#1340)

This commit is contained in:
Klas Mellbourn 2021-04-04 11:21:39 +02:00 committed by GitHub
parent 4d15cf977e
commit 8b2aab74d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2239,6 +2239,9 @@ prompt_load() {
_p9k_read_file /proc/loadavg || return _p9k_read_file /proc/loadavg || return
local load=${${(A)=_p9k__ret}[_POWERLEVEL9K_LOAD_WHICH]//,/.} local load=${${(A)=_p9k__ret}[_POWERLEVEL9K_LOAD_WHICH]//,/.}
local -F pct='100. * load / _p9k_num_cpus' local -F pct='100. * load / _p9k_num_cpus'
if (( pct < _POWERLEVEL9K_LOAD_THRESHOLD )); then
return
fi
if (( pct > 70 )); then if (( pct > 70 )); then
_p9k_prompt_segment $0_CRITICAL red "$_p9k_color1" LOAD_ICON 0 '' $load _p9k_prompt_segment $0_CRITICAL red "$_p9k_color1" LOAD_ICON 0 '' $load
elif (( pct > 50 )); then elif (( pct > 50 )); then
@ -2274,6 +2277,9 @@ _p9k_prompt_load_async() {
_p9k__load_warning= _p9k__load_warning=
_p9k__load_critical= _p9k__load_critical=
local -F pct='100. * _p9k__load_value / _p9k_num_cpus' local -F pct='100. * _p9k__load_value / _p9k_num_cpus'
if (( pct < _POWERLEVEL9K_LOAD_THRESHOLD )); then
return
fi
if (( pct > 70 )); then if (( pct > 70 )); then
_p9k__load_critical=1 _p9k__load_critical=1
elif (( pct > 50 )); then elif (( pct > 50 )); then
@ -7194,6 +7200,7 @@ _p9k_init_params() {
15) _POWERLEVEL9K_LOAD_WHICH=3;; 15) _POWERLEVEL9K_LOAD_WHICH=3;;
*) _POWERLEVEL9K_LOAD_WHICH=2;; *) _POWERLEVEL9K_LOAD_WHICH=2;;
esac esac
_p9k_declare -i POWERLEVEL9K_LOAD_THRESHOLD 0
_p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0
_p9k_declare -b POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY 0 _p9k_declare -b POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY 0
_p9k_declare -b POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY 1