add VmGUI class to misc.

lets you check if gui was launched by the api
This commit is contained in:
onyx-and-iris 2023-06-29 18:05:07 +01:00
parent b2005030f2
commit 59624ccb3e
2 changed files with 20 additions and 3 deletions

View File

@ -250,3 +250,19 @@ class Midi:
def _set(self, key: int, velocity: int):
self.cache[key] = velocity
class VmGui:
_launched = None
@property
def launched(self) -> bool:
return self._launched
@launched.setter
def launched(self, val: bool):
self._launched = val
@property
def launched_by_api(self):
return not self.launched

View File

@ -10,7 +10,7 @@ from .error import CAPIError, VMError
from .event import Event
from .inst import bits
from .kinds import KindId
from .misc import Midi
from .misc import Midi, VmGui
from .subject import Subject
from .updater import Producer, Updater
from .util import grouper, polling, script
@ -32,6 +32,7 @@ class Remote(CBindings):
self.event = Event(
{k: kwargs.pop(k) for k in ("pdirty", "mdirty", "midi", "ldirty")}
)
self.gui = VmGui()
self.logger = logger.getChild(self.__class__.__name__)
for attr, val in kwargs.items():
@ -63,8 +64,8 @@ class Remote(CBindings):
def login(self) -> NoReturn:
"""Login to the API, initialize dirty parameters"""
res = self.call(self.vm_login, ok=(0, 1))
if res == 1:
self.gui.launched = self.call(self.vm_login, ok=(0, 1)) == 0
if not self.gui.launched:
self.logger.info(
"Voicemeeter engine running but GUI not launched. Launching the GUI now."
)