Skip to content

Instantly share code, notes, and snippets.

@fi-res
Created February 25, 2026 13:39
Show Gist options
  • Select an option

  • Save fi-res/366f02ecd84e8090cbbe36f62dd363fc to your computer and use it in GitHub Desktop.

Select an option

Save fi-res/366f02ecd84e8090cbbe36f62dd363fc to your computer and use it in GitHub Desktop.
Hint to change cooling mode on coolerpad. Requires LibreHardwareMonitor opened host
from time import sleep
from win32gui import FillRect, GetDC, CreateSolidBrush, SetBkMode, SetTextColor
from win32ui import CreateFont, CreateDCFromHandle
from win32con import TRANSPARENT
from requests import get
def get_temp() -> float:
data = get('http://localhost:8085/data.json').json()['Children'][0]
return float(data['Children'][1]['Children'][3]['Children'][0]['Value'].split(' ')[0].replace(',', '.'))
def get_action(old: int, new: int) -> str:
if new > old:
return '+' + str(new - old)
elif new == old:
return '?'
else:
return '-' + str(old - new)
def show_mode(new_mode: int, action: str):
print(action)
if new_mode == 6:
text_color = 0x0000FF # red
elif new_mode == 5:
text_color = 0x00FFFF # yellow
else:
text_color = 0xFFFFFF # white
SetTextColor(hdc, text_color)
FillRect(hdc, (1800, 960, 1920, 1080), CreateSolidBrush(0))
for _ in range(25):
dc.TextOut(1820, 980, action)
sleep(0.1)
FillRect(hdc, (1800, 960, 1920, 1080), CreateSolidBrush(0))
for _ in range(25):
dc.TextOut(1820, 980, 'U' + str(new_mode))
sleep(0.1)
mode = 0
new_mode = 0
hdc = GetDC(0)
dc = CreateDCFromHandle(hdc)
dc.SelectObject(CreateFont({'name': 'Arial', 'height': 80, 'weight': 500, 'italic': False, 'underline': False}))
SetBkMode(hdc, TRANSPARENT)
while True:
temp = get_temp()
print(temp)
if temp > 85:
new_mode = 6
elif temp > 75:
new_mode = 5
elif temp > 60:
new_mode = 4
elif temp > 50:
new_mode = 3
elif temp > 40:
new_mode = 2
else:
new_mode = 1
if mode != new_mode:
if mode == 0:
mode = new_mode
show_mode(new_mode, get_action(mode, new_mode))
mode = new_mode
sleep(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment