temp 826 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. set -Eeu -o pipefail
  3. # Depends on lm-sensors (https://packages.ubuntu.com/bionic/lm-sensors)
  4. VALUE_FONT=${font:-$(xrescat i3xrocks.value.font "Source Code Pro Medium 13")}
  5. LABEL_ICON=${label_icon:-$(xrescat i3xrocks.label.thermometer )}
  6. LABEL_COLOR=${label_color:-$(xrescat i3xrocks.label.color "#7B8394")}
  7. TEMP=$(sensors | awk -F '(\\+|\\.)' '/(Core|Tdie)/ {sum+= $2; count++} END { printf "%d\n", sum/count}')
  8. if [[ ${TEMP} -gt 70 ]]
  9. then
  10. COLOR=${critical_color:-$(xrescat i3xrocks.critical.color "#BF616A")}
  11. elif [[ ${TEMP} -gt 50 ]]
  12. then
  13. COLOR=${warning:-$(xrescat i3xrocks.warning "#EBCB8B")}
  14. else
  15. COLOR=${color:-$(xrescat i3xrocks.value.color "#D8DEE9")}
  16. fi
  17. echo "<span color=\"${LABEL_COLOR}\">${LABEL_ICON}</span><span font_desc=\"${VALUE_FONT}\" color=\"${COLOR}\"> ${TEMP}℃</span>"