From 77a10e122df17f0e3914609cf0382a082da74a14 Mon Sep 17 00:00:00 2001 From: DevanshKyada27 <143169520+DevanshKyada27@users.noreply.github.com> Date: Tue, 17 Oct 2023 21:52:31 +0530 Subject: [PATCH] Create CPU Temperature Display Fixes #296 Created a CPU Temperature Display for windows using python. It have all the important libraries which are required for this code. Hope this solves the problem. Looking forward for merging this PR. --- CPU Temperature Display | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 CPU Temperature Display diff --git a/CPU Temperature Display b/CPU Temperature Display new file mode 100644 index 00000000..1a45149b --- /dev/null +++ b/CPU Temperature Display @@ -0,0 +1,39 @@ +Fixes #296 + +#python code for displaying a CPU temperature display for windows. + + +#Firstly install 'psutil' library if not installed, using, +pip install psutil + + +#Install 'plyer' library if not installed, using +pip install plyer + + +#using 'plyer' library this is the python code +import psutil +from plyer import notification + +def get_cpu_temperature(): + try: + sensors_temperatures = psutil.sensors_temperatures() + if "coretemp" in sensors_temperatures: + for entry in sensors_temperatures["coretemp"]: + if "Core" in entry.label: + return f"{entry.label}: {entry.current}°C" + except Exception as e: + return f"Error: {str(e)}" + +if __name__ == "__main__": + temperature = get_cpu_temperature() + if temperature: + notification_title = "CPU Temperature" + notification_text = f"CPU Temperature: {temperature}" + notification.notify( + title=notification_title, + message=notification_text, + app_name="CPU Temperature Checker" + ) + else: + print("Unable to retrieve CPU temperature data.")