forked from matryer/xbar-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfan-speed.5s.sh
executable file
·29 lines (27 loc) · 1.38 KB
/
fan-speed.5s.sh
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
#!/bin/bash
# <xbar.title>Fan Speed</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Eric Ripa</xbar.author>
# <xbar.author.github>eripa</xbar.author.github>
# <xbar.desc>This plugin displays the current fan speed from SMC readings (requires external 'smc' binary)</xbar.desc>
# <xbar.dependencies>smc</xbar.dependencies>
#
# 'smc' can be downloaded from: http://www.eidac.de/smcfancontrol/smcfancontrol_2_4.zip
# One-liner:
# curl -LO http://www.eidac.de/smcfancontrol/smcfancontrol_2_4.zip && unzip -d temp_dir_smc smcfancontrol_2_4.zip && cp temp_dir_smc/smcFanControl.app/Contents/Resources/smc /usr/local/bin/smc ; rm -rf temp_dir_smc smcfancontrol_2_4.zip
declare -i FANS # number of fans with smc -k FNum -r
declare -a FAN_LABEL # list available fans with smc -f
FANS=$(/usr/local/bin/smc -k FNum -r | awk '{ printf "%d\n", $4}')
# FAN_LABEL=("CPU" "ODD" "HDD") # Uncomment to add label, must 1-to-1 map the above array
FAN_SPEEDS="♨︎ " # Set your own prefix
for ((i = 0; i < FANS; i++)) ; do
FAN_SPEED=$(/usr/local/bin/smc -k F${i}Ac -r | awk '{ printf "%s\n", $3}' | grep '^[0-9]*[.][0-9]*$' | awk '{ printf "%d\n", $1}')
if [ "$FAN_SPEED" != "" ] ; then
if [ -n "${FAN_LABEL+x}" ]; then
# Add labels if FAN_LABEL is declared
FAN_SPEEDS="$FAN_SPEEDS${FAN_LABEL[$i]}: "
fi
FAN_SPEEDS="$FAN_SPEEDS$FAN_SPEED rpm "
fi
done
echo "$FAN_SPEEDS| size=12"