Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [`dropbox_status.sh`](segments/dropbox_status.sh) a new segment showing Dropbox operation statuses. [#478](https://github.com/erikw/tmux-powerline/pull/478)
- Proper error logging in segments with function `tp_err_seg()`. [#486](https://github.com/erikw/tmux-powerline/pull/486) [#485](https://github.com/erikw/tmux-powerline/pull/485)
- Adapter segments for [tmux-continuum](https://github.com/tmux-plugins/tmux-continuum/): [`tmux_continuum_save.sh`](segments/tmux_continuum_save.sh) and [`tmux_continuum_status.sh`](segments/tmux_continuum_status.sh) [#493](https://github.com/erikw/tmux-powerline/pull/493)
- [`cpu_temp.sh`](segments/cpu_temp.sh): CPU temperature. [#495](https://github.com/erikw/tmux-powerline/pull/495)
### Changed
- **Deprecation Warning:** functions `patched_font_in_use()`, `air_color()` and `format()` have been replaced by `tp_patched_font_in_use()`, `tp_air_color()` and `tp_format()` respectively and will be removed in future releases.
Please update your custom themes and segments now. [#489](https://github.com/erikw/tmux-powerline/pull/489)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Requirements for the lib to work are:
## Segment Requirements
Some segments have their own requirements. If you enable them in your theme, make sure all requirements are met for those.

* **cpu_temp.sh**: `lm_sensors` for Linux, [smctemp](https://github.com/narugit/smctemp) for Macos
* **dropbox_status.sh**: `dropbox-cli`
* **github_notifications.sh**: `jq`, `curl`
* **ifstat.sh**: `ifstat` (there is a simpler segment `ifstat_sys.sh` not using ifstat)
Expand Down
16 changes: 16 additions & 0 deletions lib/cpu_temp_helper.sh
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_at_least() {
echo "$(tp_cpu_temp_value) >= $1" | bc -l
}

2 changes: 2 additions & 0 deletions lib/headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ source "${TMUX_POWERLINE_DIR_LIB}/muting.sh"
source "${TMUX_POWERLINE_DIR_LIB}/powerline.sh"
# shellcheck source=lib/config_file.sh
source "${TMUX_POWERLINE_DIR_LIB}/config_file.sh"
# shellcheck source=lib/cpu_temp_helper.sh
source "${TMUX_POWERLINE_DIR_LIB}/cpu_temp_helper.sh"
44 changes: 44 additions & 0 deletions segments/cpu_temp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# shellcheck shell=bash
# Prints CPU temperature
# Requirements:
# lm_sensors (Linux only)
# smctemp (Macos only)

TMUX_POWERLINE_SEG_CPU_TEMP_ICON_DEFAULT=" "
TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER_DEFAULT="Package id 0\|Physical id 0\|temp1"

generate_segmentrc() {
read -r -d '' rccontents <<EORC
# CPU temperature icon
export TMUX_POWERLINE_SEG_CPU_TEMP_ICON="${TMUX_POWERLINE_SEG_CPU_TEMP_ICON_DEFAULT}"
# Linux only. Regexp to indicate a line containing CPU temperature in 'sensors' output.
# Check the output of 'sensors' program, decide which line contains desired CPU temperature
# and store an unique part of that line in this variable. It will be used by 'grep' program
# to distinct the 'CPU temperature' line from the rest output lines.
export TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER="${TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER_DEFAULT}"
EORC
echo "$rccontents"
}

run_segment() {
__process_settings

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
}

__process_settings() {
if [ -z "$TMUX_POWERLINE_SEG_CPU_TEMP_ICON" ]; then
export TMUX_POWERLINE_SEG_CPU_TEMP_ICON="${TMUX_POWERLINE_SEG_CPU_TEMP_ICON_DEFAULT}"
fi
if [ -z "$TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER" ]; then
export TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER="${TMUX_POWERLINE_SEG_CPU_TEMP_SENSORS_LINE_MARKER_DEFAULT}"
fi
}
7 changes: 7 additions & 0 deletions themes/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ if [ -z "$TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS" ]; then
#"air ${TMUX_POWERLINE_SEG_AIR_COLOR} 255"
"weather 37 255"
#"rainbarf 0 ${TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}"
# "$(
# if (($(tp_cpu_temp_at_least 60))); then
# echo "cpu_temp #ff2020 235"
# else
# echo "cpu_temp #303080 136"
# fi
# )" \
#"xkb_layout 125 117"
#"tmux_continuum_save"
#"tmux_continuum_status 14 7"
Expand Down