Advertisement
applehelpwriter

get the mac's thermal state

Apr 26th, 2017
1,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###########################################################
  2. -->> ABOUT
  3. ###########################################################
  4. (*
  5.  
  6. Phil Stokes -- 2017
  7. applehelpwriter.com
  8. sqwarq.com
  9.  
  10. *)
  11. ###########################################################
  12. -->> DESCRIPTION
  13. ###########################################################
  14. (*
  15.  
  16. Report the mac's thermal state
  17.  
  18. *)
  19. ###########################################################
  20. -->> USAGE
  21. ###########################################################
  22. (*
  23.  
  24. Requires 10.10.3 or later.
  25. Run the script when you hear the fans or are worried about the mac's thermal state.
  26.  
  27.  
  28. *)
  29. ###########################################################
  30. -->> IMPORT STATEMENTS
  31. ###########################################################
  32.  
  33. use AppleScript version "2.4" -- Yosemite (10.10) or later
  34. use scripting additions
  35. use framework "Foundation"
  36.  
  37. ###########################################################
  38. -->> COMMANDS
  39. ###########################################################
  40.  
  41. set d to (current date) as text
  42. set NSProcessInfo to a reference to current application's NSProcessInfo
  43. set procInfo to NSProcessInfo's alloc's init
  44. set n to procInfo's thermalState()
  45. set msg to "Error - could not get thermal state."
  46. if n = 0 then
  47. set msg to "NSProcessInfoThermalStateNominal - No corrective action needed."
  48. else if n = 1 then
  49. set msg to "NSProcessInfoThermalStateFair - The system has reached a state where fans may become audible."
  50. else if n = 2 then
  51. set msg to "NSProcessInfoThermalStateSerious - Fans are running at maximum speed, system performance maybe impacted. Recommendation: reduce application's usage of CPU, GPU and I/O, if possible. Switch to lower quality visual effects, reduce frame rates."
  52. else if n = 3 then
  53. set msg to "NSProcessInfoThermalStateCritical - System performance is significantly impacted and the Mac needs to cool down. Recommendation: reduce application's usage of CPU, GPU, and I/O to the minimum level needed to respond to user actions. Consider stopping use of camera and other peripherals if your application is using them."
  54. end if
  55. set msg to d & return & return & msg
  56. return msg
  57. # display dialog msg with icon 1 buttons "OK" default button "OK" with title "NSProcessInfoThermalState"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement