Merge pull request #795 from sayansil/main

Add active gpu module using optimus-manager
This commit is contained in:
tobi-wan-kenobi 2021-06-25 15:49:59 +02:00 committed by GitHub
commit 447d094fe2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,36 @@
"""Displays currently active gpu by optimus-manager
Requires the following packages:
* optimus-manager
"""
import subprocess
import core.module
import core.widget
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):
cmd = ["optimus-manager", "--print-mode"]
output = (
subprocess.Popen(cmd, stdout=subprocess.PIPE)
.communicate()[0]
.decode("utf-8")
.lower()
)
if "intel" in output:
self.__gpumode = "Intel"
elif "nvidia" in output:
self.__gpumode = "Nvidia"
elif "amd" in output:
self.__gpumode = "AMD"