From 8fc96638ca931fe173ee82555190d98bae0d70e9 Mon Sep 17 00:00:00 2001 From: Pawel Chalkowski Date: Sat, 5 Feb 2022 18:51:52 +0100 Subject: [PATCH] Added support for system temperature on Raspberry PI --- README.md | 1 + scripts/dracula.sh | 5 +++++ scripts/rpi_temp.sh | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100755 scripts/rpi_temp.sh diff --git a/README.md b/README.md index f4b3c513..243fb262 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul * When prefix is enabled smiley face turns from green to yellow * When charging, 'AC' is displayed * If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature +* System temperature on Raspberry PI ## Compatibility diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f47..e83cd3e0 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -192,6 +192,11 @@ main() fi fi + if [ $plugin = "rpi-temp" ]; then + IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-rpi-temp-colors" "green dark_gray") + script="#($current_dir/rpi_temp.sh)" + fi + if $show_powerline; then tmux set-option -ga status-right "#[fg=${!colors[0]},bg=${powerbg},nobold,nounderscore,noitalics]${right_sep}#[fg=${!colors[1]},bg=${!colors[0]}] $script " powerbg=${!colors[0]} diff --git a/scripts/rpi_temp.sh b/scripts/rpi_temp.sh new file mode 100755 index 00000000..25898c2e --- /dev/null +++ b/scripts/rpi_temp.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +get_temp() { + echo "$(vcgencmd measure_temp | sed 's/temp=//')" +} + +main() { + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + echo "$(get_temp)" + sleep $RATE +} + +# run main driver +main