added coretemp.sh to i3block_shell scripts collection
This commit is contained in:
parent
fd44a722be
commit
6472c4ea2d
|
@ -29,6 +29,7 @@ None standard Python dependencies:
|
|||
|
||||
## i3block_shell
|
||||
A bunch of simple bash scripts to be called via i3blocks.
|
||||
* **coretemp.sh** Echos average temperature of all CPU cores by parsing output of `sensors` from package *lm_sensors*
|
||||
* **date.sh**: Echos the current date
|
||||
* on left click: uses notify-send to print current three month calendar
|
||||
* **df.sh**: Echos current diskfree level of the root partition
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
# print temp for i3 blocks
|
||||
# reads output from sensors command
|
||||
|
||||
all_sensors=$(sensors | grep -E "Core [0-9]" | awk '{print $3}' \
|
||||
| cut -d'.' -f 1 | sed 's/+//g')
|
||||
|
||||
# build array
|
||||
sensors_arr=()
|
||||
while IFS= read -r line; do
|
||||
sensors_arr+=("$line")
|
||||
done <<< "$all_sensors"
|
||||
|
||||
# calc average
|
||||
cores="${#sensors_arr[@]}"
|
||||
sum_cores=$(IFS=+; echo "$((${sensors_arr[*]}))")
|
||||
temp=$(( sum_cores / cores ))
|
||||
|
||||
# split based on temp
|
||||
if [[ $temp -le 60 ]]; then
|
||||
printmain=" $temp°C"
|
||||
printsmall=""
|
||||
printcolor=""
|
||||
elif [[ $temp -gt 60 ]] && [[ $temp -lt 75 ]]; then
|
||||
printmain=" $temp°C"
|
||||
printsmall=""
|
||||
printcolor="#FFFF00"
|
||||
elif [[ $temp -ge 75 ]]; then
|
||||
printmain=" $temp°C"
|
||||
printsmall=""
|
||||
printcolor="#FF0000"
|
||||
else
|
||||
printcolor=""
|
||||
fi
|
||||
|
||||
echo "$printmain"
|
||||
echo "$printsmall"
|
||||
echo "$printcolor"
|
||||
|
||||
##
|
||||
exit 0
|
Loading…
Reference in New Issue