add configuration options and temperature mark

This commit is contained in:
François Schmidts 2013-04-22 23:22:32 +02:00
parent 454dfddd44
commit 43e426d0e8
3 changed files with 12 additions and 5 deletions

View File

@ -13,6 +13,7 @@ if [[ "$(locale -k LC_CTYPE | sed -n 's/^charmap="\(.*\)"/\1/p')" == *"UTF-8"* ]
LP_MARK_BATTERY="⌁" # in front of the battery charge LP_MARK_BATTERY="⌁" # in front of the battery charge
LP_MARK_ADAPTER="⏚" # displayed when plugged LP_MARK_ADAPTER="⏚" # displayed when plugged
LP_MARK_LOAD="⌂" # in front of the load LP_MARK_LOAD="⌂" # in front of the load
LP_MARK_TEMP="θ" # in front of the temp
LP_MARK_PROXY="↥" # indicate a proxy in use LP_MARK_PROXY="↥" # indicate a proxy in use
LP_MARK_HG="☿" # prompt mark in hg repositories LP_MARK_HG="☿" # prompt mark in hg repositories
LP_MARK_SVN="‡" # prompt mark in svn repositories LP_MARK_SVN="‡" # prompt mark in svn repositories
@ -26,6 +27,7 @@ else
LP_MARK_BATTERY="b" LP_MARK_BATTERY="b"
LP_MARK_ADAPTER="p" LP_MARK_ADAPTER="p"
LP_MARK_LOAD="c" LP_MARK_LOAD="c"
LP_MARK_TEMP="T"
LP_MARK_PROXY="^" LP_MARK_PROXY="^"
LP_MARK_HG="m" LP_MARK_HG="m"
LP_MARK_SVN="=" LP_MARK_SVN="="

View File

@ -233,6 +233,7 @@ _lp_source_config()
LP_MARK_BATTERY=${LP_MARK_BATTERY:-"⌁"} LP_MARK_BATTERY=${LP_MARK_BATTERY:-"⌁"}
LP_MARK_ADAPTER=${LP_MARK_ADAPTER:-"⏚"} LP_MARK_ADAPTER=${LP_MARK_ADAPTER:-"⏚"}
LP_MARK_LOAD=${LP_MARK_LOAD:-"⌂"} LP_MARK_LOAD=${LP_MARK_LOAD:-"⌂"}
LP_MARK_TEMP=${LP_MARK_TEMP:-"θ"}
LP_MARK_PROXY=${LP_MARK_PROXY:-"↥"} LP_MARK_PROXY=${LP_MARK_PROXY:-"↥"}
LP_MARK_HG=${LP_MARK_HG:-"☿"} LP_MARK_HG=${LP_MARK_HG:-"☿"}
LP_MARK_SVN=${LP_MARK_SVN:-"‡"} LP_MARK_SVN=${LP_MARK_SVN:-"‡"}
@ -1199,18 +1200,19 @@ _lp_load_color()
fi fi
} }
_lp_temp() { _lp_temperature() {
[[ "$LP_ENABLE_TEMP" != 1 ]] && return [[ "$LP_ENABLE_TEMP" != 1 ]] && return
local count=0 local count=0
local temperature=0 local temperature=0
for i in $(sensors | grep -E "Core" | for i in $(sensors | grep -E "^(Core|temp)" |
sed -e 's/.*: *+//g' -e 's/\..°.*//g'); do sed -r "s/.*: *\+([0-9]*)\..°.*/\1/g"); do
temperature=$(($temperature+$i)) temperature=$(($temperature+$i))
count=$(($count+1)) count=$(($count+1))
done done
temperature=$(($temperature/$count)) temperature=$(($temperature/$count))
if [[ $temperature -ge $LP_TEMP_THRESHOLD ]]; then if [[ $temperature -ge $LP_TEMP_THRESHOLD ]]; then
echo -ne "$(_lp_color_map $temperature)$temperature°${NO_COL}" echo -ne "$(_lp_color_map $temperature)${LP_MARK_TEMP}$temperature°${NO_COL}"
fi fi
} }
@ -1396,7 +1398,7 @@ _lp_set_prompt()
# left of main prompt: space at right # left of main prompt: space at right
LP_JOBS=$(_lp_sr "$(_lp_jobcount_color)") LP_JOBS=$(_lp_sr "$(_lp_jobcount_color)")
LP_TEMP=$(_lp_sr "$(_lp_temp)") LP_TEMP=$(_lp_sr "$(_lp_temperature)")
LP_LOAD=$(_lp_sr "$(_lp_load_color)") LP_LOAD=$(_lp_sr "$(_lp_load_color)")
LP_BATT=$(_lp_sr "$(_lp_battery_color)") LP_BATT=$(_lp_sr "$(_lp_battery_color)")
LP_TIME=$(_lp_sr "$(_lp_time)") LP_TIME=$(_lp_sr "$(_lp_time)")

View File

@ -95,6 +95,9 @@ LP_ENABLE_BZR=1
# Recommended value is 0 # Recommended value is 0
LP_ENABLE_TIME=0 LP_ENABLE_TIME=0
# Show average system temperature
LP_ENABLE_TEMP=1
# When showing time, use an analog clock instead of numeric values. # When showing time, use an analog clock instead of numeric values.
# The analog clock is "accurate" to the nearest half hour. # The analog clock is "accurate" to the nearest half hour.
# You must have a unicode-capable terminal and a font with the "CLOCK" # You must have a unicode-capable terminal and a font with the "CLOCK"