aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2016-05-03 00:29:32 +0300
committerBen Hilburn <bhilburn@gmail.com>2016-05-03 00:29:32 +0300
commitaf7d95248009e542f75aa8034c379518b71f96dc (patch)
tree48884a16d580019bde33fd327670ac31b4d354d0 /powerlevel9k.zsh-theme
parent24fac490507996dbd015e11e0c13b8ee05014d50 (diff)
parent61a0cee4f513f71c17737abd2fe1d3d5e9aa67e7 (diff)
Merge pull request #252 from rawkode/feature/better-battery-core-improvements
Improvements to load prompt, now reporting warning and critical at 50…
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme17
1 files changed, 11 insertions, 6 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index d583eaab..224e34cc 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -578,30 +578,35 @@ prompt_ip() {
prompt_load() {
# The load segment can have three different states
local current_state="unknown"
+ local cores
+
typeset -AH load_states
load_states=(
'critical' 'red'
'warning' 'yellow'
'normal' 'green'
)
+
if [[ "$OS" == "OSX" ]]; then
- load_avg_5min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
+ load_avg_1min=$(sysctl vm.loadavg | grep -o -E '[0-9]+(\.|,)[0-9]+' | head -n 1)
+ cores=$(sysctl -n hw.logicalcpu)
else
- load_avg_5min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
+ load_avg_1min=$(grep -o "[0-9.]*" /proc/loadavg | head -n 1)
+ cores=$(nproc)
fi
# Replace comma
- load_avg_5min=${load_avg_5min//,/.}
+ load_avg_1min=${load_avg_1min//,/.}
- if [[ "$load_avg_5min" -gt 10 ]]; then
+ if [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.7") ]]; then
current_state="critical"
- elif [[ "$load_avg_5min" -gt 3 ]]; then
+ elif [[ "$load_avg_1min" -gt $(bc -l <<< "${cores} * 0.5") ]]; then
current_state="warning"
else
current_state="normal"
fi
- "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_5min" 'LOAD_ICON'
+ "$1_prompt_segment" "${0}_${current_state}" "$2" "${load_states[$current_state]}" "$DEFAULT_COLOR" "$load_avg_1min" 'LOAD_ICON'
}
# Node version