fuhsjr00 / bug.n

Tiling Window Manager for Windows
GNU General Public License v3.0
3.36k stars 214 forks source link

Support showing CPU/GPU temperature in bar #156

Closed robrtsql closed 6 years ago

robrtsql commented 6 years ago

I like bug.n a lot--I'm planning on using it to replace the default Windows 10 taskbar (and for managing windows, of course). However, before I can do that, I would want to be able to see the temperature that my CPU and graphics card is running at.

I am looking at trying to extend the ResourceMonitor to be able to read temperature--if I were successful, would my changes be considered for merging?

Also, I'm an absolute novice at AHK, and don't even know if what I'm attempting is possible (I know lots of closed-source software does it, but I don't know how I would obtain temperature info), so tips are appreciated!

robrtsql commented 6 years ago

After doing some research, I found that there is no 'universal' way to access temperature information, since it's largely dependent on the hardware you're using. Because of that, I opted to use OpenHardwareMonitor. Because it's a dependency of my changes, they're probably not suitable for being merged in.

However, if somebody finds this issue down the road and is wondering how to get your temperature information into the status bar: if your hardware is supported by OpenHardwareMonitor, install it and add this to your Config_readinAny() function in Config.ahk:

  objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\OpenHardwareMonitor")
  colItems := objWMIService.ExecQuery("SELECT Value FROM Sensor WHERE Name='CPU Package' AND SensorType='Temperature'")._NewEnum
  while colItems[objItem]
  {
    text .= "| CPU:  " Round(objItem.Value) "C "
  }

  colItems := objWMIService.ExecQuery("SELECT Value FROM Sensor WHERE Name='GPU Core' AND SensorType='Temperature'")._NewEnum
  while colItems[objItem]
  {
    text .= "| GPU:  " Round(objItem.Value) "C "
  }

If OpenHardwareMonitor is running, the CPU and GPU temperature values from OpenHardwareMonitor will appear in your status bar. Note that OpenHardwareMonitor has to be running when you start bug.n: if it wasn't, refresh bug.n to see the temperatures.