-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRaspberryPi4TemperaturePromptPlugin.zsh
48 lines (38 loc) · 1.78 KB
/
RaspberryPi4TemperaturePromptPlugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Raspberry Pi Temp
#
# A simple temp updater on the spacebar prompt.
# Link: https://www.raspberrypi4temp.xyz
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
SPACESHIP_RASPBERRYPI4TEMP_SHOW="${SPACESHIP_RASPBERRYPI4TEMP_SHOW=true}"
SPACESHIP_RASPBERRYPI4TEMP_PREFIX="${SPACESHIP_RASPBERRYPI4TEMP_PREFIX=""}"
SPACESHIP_RASPBERRYPI4TEMP_SUFFIX="${SPACESHIP_RASPBERRYPI4TEMP_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_RASPBERRYPI4TEMP_SYMBOL="${SPACESHIP_RASPBERRYPI4TEMP_SYMBOL="🌡️"}"
SPACESHIP_RASPBERRYPI4TEMP_COLOR="${SPACESHIP_RASPBERRYPI4TEMP_COLOR="white"}"
# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------
# Show raspberrypi4temp status
# spaceship_ prefix before section's name is required!
# Otherwise this section won't be loaded.
spaceship_raspberrypi4temp() {
# If SPACESHIP_RASPBERRYPI4TEMP_SHOW is false, don't show raspberrypi4temp section
[[ $SPACESHIP_RASPBERRYPI4TEMP_SHOW == false ]] && return
# # Check if raspberrypi4temp command is available for execution
# spaceship::exists raspberrypi4temp || return
local 'cpu_temp'
local 'gpu_temp'
cpu_temp="CPU $(($(</sys/class/thermal/thermal_zone0/temp)/1000))'C"
gpu_temp="GPU ${$(vcgencmd measure_temp): -6}"
# Exit section if variable is empty
[[ -z $cpu_temp ]] && return
[[ -z $gpu_temp ]] && return
# Display raspberrypi4temp section
spaceship::section \
"$SPACESHIP_RASPBERRYPI4TEMP_COLOR" \
"$SPACESHIP_RASPBERRYPI4TEMP_PREFIX" \
"$SPACESHIP_RASPBERRYPI4TEMP_SYMBOL $cpu_temp $gpu_temp" \
"$SPACESHIP_RASPBERRYPI4TEMP_SUFFIX"
}