#!/bin/sh

##########################################################################################################
#																										 
#    Copyright © 2022 To Cyb3rTh1eveZ																	 
#																										 
#     ██████╗██╗   ██╗██████╗ ██████╗ ██████╗ ████████╗██╗  ██╗ ██╗███████╗██╗   ██╗███████╗███████╗	 
#    ██╔════╝╚██╗ ██╔╝██╔══██╗╚════██╗██╔══██╗╚══██╔══╝██║  ██║███║██╔════╝██║   ██║██╔════╝╚══███╔╝     
#    ██║      ╚████╔╝ ██████╔╝ █████╔╝██████╔╝   ██║   ███████║╚██║█████╗  ██║   ██║█████╗    ███╔╝      
#    ██║       ╚██╔╝  ██╔══██╗ ╚═══██╗██╔══██╗   ██║   ██╔══██║ ██║██╔══╝  ╚██╗ ██╔╝██╔══╝   ███╔╝       
#    ╚██████╗   ██║   ██████╔╝██████╔╝██║  ██║   ██║   ██║  ██║ ██║███████╗ ╚████╔╝ ███████╗███████╗     
#     ╚═════╝   ╚═╝   ╚═════╝ ╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝ ╚═╝╚══════╝  ╚═══╝  ╚══════╝╚══════╝     
#																										 
#																										 
#																										 
#    Copyright (C) Mahmoud Mohamed (Ozil)  <https://github.com/mmsaeed509>								 
#    LICENSE © GNU-GPL3																					 
#																										 
##########################################################################################################

heatSensors=$(sensors | grep -m 1 id | awk '{print substr($4, 2, length($4)-5)}')

# from  0°C to 40°C print ->  
if [[ "$heatSensors" -le 40 ]] 
	then
		# the ' %{T3} ' -> pass font type to polybar config file 
		# the selected font type is number 3, which is (font-3 = "Iosevka:style=bold:"size=12;3" )
		echo "%{T4} %{F#D4BFFF}$heatSensors°C"

# from 40°C to 60°C print -> 
elif [[ "$heatSensors" -le 60 ]] 
	then
		echo "%{T4} %{F#D4BFFF}$heatSensors°C"

# from 60°C to 85°C print -> 
elif [[ "$heatSensors" -le 85 ]]
	then
		echo "%{T4} %{F#D4BFFF}$heatSensors°C"

# from 85°C to +... print ->  
elif [[ "$heatSensors" -gt 85 ]] 
	then
		# the  ' -n "%{F#FF0008}"  ' -> red font as 85°C to +... is the default warn temperature
		echo -n "%{T4}%{F#FF0008} %{F#FF0008}$heatSensors°C"
fi
