💾 Archived View for gemini.mcgillij.dev › cpu_governor.gmi captured on 2023-11-04 at 11:27:22. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
:author:
mcgillij
:category:
Python
:date:
2021-01-29 22:49
:tags:
Linux, Python, i3, py3status, #100DaysToOffload
:slug:
cpu-governor-py3status
:summary:
Another py3status module for i3, this time for showing the CPU governor
:cover_image:
cpu_cover.png
A simple module for py3status written to show the status of which CPU governor that your currently using.
If your anything like me, and change the governor quite often for different workloads, this is handy information to have on your desktop to remind you to change it back when your done doing processor intensive tasks.
[image: cpu_governor screenshot]
This is what the module looks like on my system## Code
Below is the entirety of the code.
# -*- coding: utf-8 -*- """ Module to report the CPU governor state in py3status bar """ class Py3status: cache_timeout = 600 format = 'đź’»: {status}' def _get_cpu_status(self): try: status = self.py3.command_output(["cat", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"]) return {'status': status.strip()} except self.py3.CommandError as ce: return len(ce.output.splitlines()) def cpu_governor_status(self): status = self._get_cpu_status() full_text = self.py3.safe_format(self.format, status) return { 'full_text': full_text, 'cached_until': self.py3.time_in(self.cache_timeout) } if __name__ == "__main__": from py3status.module_test import module_test module_test(Py3status)
To install the module just copy it to "~/.i3/py3status/" and add the following line to your "~/.config/i3/i3status.conf"
order += "cpu_governor"
That’s it, restart your i3 session and you should be able to see your cpu governor setting.
The source is also
if you don’t want to copy / paste from a webpage.