Add anion155's HDD segment

pull/22/head
Mikhaylov Anton 8 years ago committed by Ben Hilburn
parent 353cb7a497
commit 46ef589b63

@ -34,6 +34,7 @@ case $POWERLEVEL9K_MODE in
TEST_ICON $'\uE891' #  TEST_ICON $'\uE891' # 
TODO_ICON $'\u2611' # ☑ TODO_ICON $'\u2611' # ☑
BATTERY_ICON $'\uE894' #  BATTERY_ICON $'\uE894' # 
HDD_ICON $'\uD83D\uDDB4' # 🖴
OK_ICON $'\u2713' # ✓ OK_ICON $'\u2713' # ✓
FAIL_ICON $'\u2718' # ✘ FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF' SYMFONY_ICON 'SF'
@ -97,6 +98,7 @@ case $POWERLEVEL9K_MODE in
TEST_ICON $'\uF291' #  TEST_ICON $'\uF291' # 
TODO_ICON $'\u2611' # ☑ TODO_ICON $'\u2611' # ☑
BATTERY_ICON $'\U1F50B' # 🔋 BATTERY_ICON $'\U1F50B' # 🔋
HDD_ICON $'\uF0A0 ' # 
OK_ICON $'\u2713' # ✓ OK_ICON $'\u2713' # ✓
FAIL_ICON $'\u2718' # ✘ FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF' SYMFONY_ICON 'SF'

@ -337,6 +337,50 @@ prompt_background_jobs() {
fi fi
} }
# Segment to indicate hdd available level.
prompt_hdd_usage() {
local current_state="unknown"
typeset -AH hdd_usage_states
hdd_usage_states=(
'normal' 'green'
'warning' 'yellow'
'critical' 'red'
)
# local df="$(df -k . | sed -n '2p')"
# local size="$(echo $df | awk '{ print $2 }')"
# local avail="$(echo $df | awk '{ print $4 }')"
# local level="$(printf %.0f $(( avail * 100.0 / size )))"
local level="${$(df -k . | sed -n '2p' | awk '{ print $5 }')%%\%}"
level="$(( 100 - level ))"
set_default POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL 10
set_default POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL 5
if [ $level -gt $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then
# Default behavior: Show message always
set_default POWERLEVEL9K_HDD_USAGE_ONLY_WARNING false
if [[ "$POWERLEVEL9K_HDD_USAGE_ONLY_WARNING" != false ]]; then
return
fi
fi
current_state='normal'
if [ $level -le $POWERLEVEL9K_HDD_USAGE_WARNING_LEVEL ]; then
current_state='warning'
fi
if [ $level -le $POWERLEVEL9K_HDD_USAGE_CRITICAL_LEVEL ]; then
current_state='critical'
fi
local message="$level"
# Draw the prompt_segment
if [[ -n $level ]]; then
"$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${hdd_usage_states[$current_state]}" "$message" 'HDD_ICON'
fi
}
prompt_battery() { prompt_battery() {
# The battery can have four different states - default to 'unknown'. # The battery can have four different states - default to 'unknown'.
local current_state='unknown' local current_state='unknown'

Loading…
Cancel
Save