-
Notifications
You must be signed in to change notification settings - Fork 527
CPU temperature segment #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # shellcheck shell=bash | ||
|
|
||
| tp_cpu_temp_value() { | ||
| if tp_shell_is_macos; then | ||
| smctemp -c | bc -l | ||
| elif tp_shell_is_linux; then | ||
| sensors \ | ||
| | grep "$TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER" -m 1 \ | ||
| | sed -e 's/[^+]*+\([\s0-9\.]*\).*/\1/' | bc -l | ||
| fi | ||
| } | ||
|
|
||
| tp_cpu_temp_is_high() { | ||
| echo "$(tp_cpu_temp_value) >= $TMUX_POWERLINE_SEG_CPU_TEMP_HIGH" | bc -l | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # shellcheck shell=bash | ||
| # Prints CPU temperature | ||
| # Requirements: | ||
| # lm_sensors (Linux only) | ||
| # smctemp (Macos only) | ||
|
|
||
| TMUX_POWERLINE_SEG_CPU_TEMP_HIGH=${TMUX_POWERLINE_SEG_CPU_TEMP_HIGH:-60} | ||
| TMUX_POWERLINE_SEG_CPU_TEMP_ICON="${TMUX_POWERLINE_SEG_CPU_TEMP_ICON:- }" | ||
erikw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER="${TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER:-Package id 0\|Physical id 0\|temp1}" | ||
|
||
|
|
||
| generate_segmentrc() { | ||
| read -r -d '' rccontents <<EORC | ||
| # The minimum temperature considered "high" by tp_cpu_temp_is_high function | ||
| export TMUX_POWERLINE_SEG_CPU_TEMP_HIGH=${TMUX_POWERLINE_SEG_CPU_TEMP_HIGH} | ||
| # CPU temperature icon | ||
| export TMUX_POWERLINE_SEG_CPU_TEMP_ICON="${TMUX_POWERLINE_SEG_CPU_TEMP_ICON}" | ||
| # Regexp to indicate a line containing CPU temperature in sensors output | ||
erikw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER="${TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER}" | ||
| EORC | ||
| echo "$rccontents" | ||
| } | ||
|
|
||
| run_segment() { | ||
| local temp | ||
| temp=$(tp_cpu_temp_value) | ||
|
|
||
| if [ -n "$temp" ]; then | ||
| echo "${TMUX_POWERLINE_SEG_CPU_TEMP_ICON}${temp}°" | ||
| return 0 | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.