Skip to content

Commit

Permalink
Formated the output of CPU temperature srcipt iiitl#8
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyanshu-ryu committed Mar 17, 2024
1 parent 96850b2 commit 0deedad
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/cpu-temperature
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/usr/bin/env bash

grep -E 'Tctl|Tdie|Package id' /sys/class/hwmon/hwmon*/temp*_label | head -n1 | cut -d':' -f1 | sed 's/label/input/' | xargs cat


# Following script outputs current cpu die temperature in milidegree-celcius, convert it to celcius and fahrenheit and display as:
#
# Celcius: 42.0 C
# Fahrenheit: 107.6 F

temp_milidegree=$(grep -E 'Tctl|Tdie|Package id' /sys/class/hwmon/hwmon*/temp*_label | head -n1 | cut -d':' -f1 | sed 's/label/input/' | xargs cat)
temp_celcius=$(echo "scale=1; $temp_milidegree / 1000" | bc)
temp_fahrenheit=$(echo "scale=1; ($temp_celcius * 9/5) + 32" | bc)

echo "Celcius:" $temp_celcius "C"
echo "Fahrenheit:" $temp_fahrenheit "F"

0 comments on commit 0deedad

Please sign in to comment.