[modules/prime] update to latest API

This commit is contained in:
tobi-wan-kenobi 2020-04-21 20:33:34 +02:00
parent 8278e7c5a1
commit cf32da4375

View file

@ -25,36 +25,33 @@ Requires the following executable:
""" """
import bumblebee.util import core.module
import bumblebee.input import core.widget
import bumblebee.output import core.input
import bumblebee.engine
class Module(bumblebee.engine.Module): import util.cli
def __init__(self, engine, config):
super(Module, self).__init__(engine, config, class Module(core.module.Module):
bumblebee.output.Widget(full_text=self.query) def __init__(self, config):
) super().__init__(config, core.widget.Widget(self.query))
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
cmd=self._chooseNvidia) core.input.register(self, button=core.input.LEFT_MOUSE,
engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, cmd=self.__chooseNvidia)
cmd=self._chooseIntel) core.input.register(self, button=core.input.RIGHT_MOUSE,
cmd=self.__chooseIntel)
self.nvidiastring = self.parameter('nvidiastring', 'nv') self.nvidiastring = self.parameter('nvidiastring', 'nv')
self.intelstring = self.parameter('intelstring', 'it') self.intelstring = self.parameter('intelstring', 'it')
def _chooseNvidia(self, event): def __chooseNvidia(self, event):
bumblebee.util.execute('sudo prime-select nvidia') util.cli.execute('sudo prime-select nvidia')
def _chooseIntel(self, event): def __chooseIntel(self, event):
bumblebee.util.execute('sudo prime-select intel') util.cli.execute('sudo prime-select intel')
def _prev_keymap(self, event):
self._set_keymap(-1)
def query(self, widget): def query(self, widget):
try: try:
res = bumblebee.util.execute('prime-select query') res = util.cli.execute('prime-select query')
except RuntimeError: except RuntimeError:
return 'n/a' return 'n/a'