2021-06-24 19:47:35 +02:00
|
|
|
"""Displays currently active gpu by optimus-manager
|
|
|
|
Requires the following packages:
|
|
|
|
|
|
|
|
* optimus-manager
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import core.module
|
|
|
|
import core.widget
|
|
|
|
|
2021-06-30 08:01:42 +02:00
|
|
|
import util.cli
|
2021-06-24 19:47:35 +02:00
|
|
|
|
|
|
|
class Module(core.module.Module):
|
|
|
|
def __init__(self, config, theme):
|
|
|
|
super().__init__(config, theme, core.widget.Widget(self.output))
|
|
|
|
self.__gpumode = ""
|
|
|
|
|
|
|
|
def output(self, _):
|
|
|
|
return "GPU: {}".format(self.__gpumode)
|
|
|
|
|
|
|
|
def update(self):
|
2021-06-30 08:01:42 +02:00
|
|
|
cmd = "optimus-manager --print-mode"
|
|
|
|
output = util.cli.execute(cmd).strip()
|
2021-06-24 19:47:35 +02:00
|
|
|
|
|
|
|
if "intel" in output:
|
|
|
|
self.__gpumode = "Intel"
|
|
|
|
elif "nvidia" in output:
|
|
|
|
self.__gpumode = "Nvidia"
|
|
|
|
elif "amd" in output:
|
|
|
|
self.__gpumode = "AMD"
|