ob-cpufreq.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python2
  2. # The script base is taken from http://openbox.org/wiki/Openbox:Pipemenus
  3. # CPU FREQUENCY INFO
  4. file = open('/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq','r')
  5. tmp = file.readline()
  6. minfreq = int(tmp) / 1000
  7. file.close()
  8. file = open('/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq','r')
  9. tmp = file.readline()
  10. maxfreq = int(tmp) / 1000
  11. file.close()
  12. file = open('/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq','r')
  13. tmp = file.readline()
  14. curfreq = int(tmp) / 1000
  15. file.close()
  16. # TEMPERATURES
  17. # SET YOUR TEMPERATURE ZONE TO YOUR WITH THIS COMMAND
  18. #
  19. # for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done
  20. file = open('/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input','r')
  21. tmp = file.readline()
  22. cputemp = int(tmp) / 1000
  23. file.close()
  24. file = open('/sys/devices/pci0000:00/0000:00:01.0/hwmon/hwmon5/temp1_input','r')
  25. tmp = file.readline()
  26. gputemp = int(tmp) / 1000
  27. file.close()
  28. # WRITING TO PIPEMENU
  29. print "<openbox_pipe_menu>"
  30. print " <separator label=\"CPU FREQUENCY\" />"
  31. print " <item label=\"Minimum: %dMHz\"/>" % minfreq
  32. print " <item label=\"Maximum: %dMHz\"/>" % maxfreq
  33. print " <item label=\"Current: %dMHz\"/>" % curfreq
  34. print " <separator label=\"HW TEMPERATURE\" />"
  35. print " <item label=\"CPU : %dc\"/>" % cputemp
  36. print " <item label=\"GPU : %dc\"/>" % gputemp
  37. print "</openbox_pipe_menu>"