Beispiel #1
0
 def __init__(self, window, settings, path=''):
     # Retrieve settings
     ### UI Related
     geometry = settings['geometry'] if 'geometry' in settings else [
         0, 0, 25, 7
     ]
     self._currentProgram = ""
     # Process alignment
     if len(geometry) == 3: geometry.append(7)
     geometry.insert(2, geometry[2])
     geometry, _ = getPosFromGeometry(geometry)
     ### Create cache folder if it doesn't exist
     self._iconsPath = path + '/cache/icons/'
     if not os.path.exists(self._iconsPath):
         os.makedirs(self._iconsPath)
     # Create components
     self._label = QLabel(window)
     self._label.setGeometry(geometry[0], geometry[1], geometry[2],
                             geometry[3])
     self._label.setAttribute(Qt.WA_TranslucentBackground)
     self._label.show()
     # Bind Server
     RyderClient().addEndPoint('foregroundProcessName',
                               self._newProcessName)
     RyderClient().addEndPoint('foregroundProcessIcon',
                               self._newProcessIcon)
     RyderClient().addEndPoint('on_connect', self._onConnect)
Beispiel #2
0
 def deleteLater(self):
     # Remove Server Bindings
     RyderClient().removeEndPoint('foregroundProcessName',
                                  self._newProcessName)
     RyderClient().removeEndPoint('foregroundProcessIcon',
                                  self._newProcessIcon)
     RyderClient().removeEndPoint('on_connect', self._onConnect)
     # Remove from layout
     self._label.deleteLater()
Beispiel #3
0
 def deleteLater(self):
     # Remove Server Bindings
     RyderClient().removeEndPoint('on_connect', self._onConnect)
     RyderClient().removeEndPoint('appLauncherData', self._updateAppDrawer)
     RyderClient().removeEndPoint('appLauncherUpdate',
                                  self._requestNewAppLauncherData)
     # Remove from layout
     for i in range(len(self._buttons)):
         self._buttons[i].deleteLater()
     self._buttons.clear()
 def create(self, path):
     if not self._instantiated:
         self._instantiated = True
         self._cache = path + '/cache/'
         if not os.path.exists(self._cache):
             os.makedirs(self._cache)
         # Discord Client
         intents = discord.Intents.none()
         discord.Client.__init__(self, intents=intents)
         # Bind EndPoints
         RyderClient().addEndPoint('on_connect', self._run)
         RyderClient().addEndPoint('discordLogin', self._discordLoginData)
Beispiel #5
0
 def login_error(self, data):
     print("Login error")
     print(data)
     if data == EResult.InvalidPassword:
         if self._notification != None:
             self._notification('Steam', 'Login', 'Requesting Login Data')
         RyderClient().send("[\"steamLogin\"]")
Beispiel #6
0
 def onClick(self, i: int):
     audio = self._profiles[i]
     print("Request Audio Profile: " + audio['playbackDevice'] + ", " +
           audio['playbackDeviceCommunication'] + ", " +
           audio['recordingDevice'])
     RyderClient().send("[\"audioProfile\",\"" + audio['playbackDevice'] +
                        "\",\"" + audio['playbackDeviceCommunication'] +
                        "\",\"" + audio['recordingDevice'] + "\"]")
     self.close()
Beispiel #7
0
 def __init__(self, window, settings, path='', handleWindowSize=False):
     # Retrieve settings
     self._window = window
     self._handleWindowSize = handleWindowSize
     pos = settings['pos'] if 'pos' in settings else [0, 0]
     alignment = settings['alignment'] if 'alignment' in settings else 7
     self._max_size = settings['size'] if 'size' in settings else [100, 100]
     self._gap = settings['gap'] if 'gap' in settings else 25
     self._iconSize = settings['iconSize'] if 'iconSize' in settings else 60
     # Process alignment
     pos, _ = getPosFromAlignment(pos, self._max_size, alignment)
     # Create cache folder if it doesn't exist
     self._iconsPath = path + '/cache/app_drawer/'
     if not os.path.exists(self._iconsPath):
         os.makedirs(self._iconsPath)
     # Bind Server
     RyderClient().addEndPoint('on_connect', self._onConnect)
     RyderClient().addEndPoint('appLauncherData', self._updateAppDrawer)
     RyderClient().addEndPoint('appLauncherUpdate',
                               self._requestNewAppLauncherData)
Beispiel #8
0
 def create(self, path):
     if not self._instantiated:
         self._instantiated = True
         self._cache = path + '/cache/'
         if not os.path.exists(self._cache):
             os.makedirs(self._cache)
         # Steam Client
         self._steamClient = SteamClient()
         # Hook Steam Client Events
         self._steamClient.on(SteamClient.EVENT_AUTH_CODE_REQUIRED, self.auth_code_prompt)
         self._steamClient.on("FriendMessagesClient.IncomingMessage#1", self.handle_message)
         self._steamClient.on(SteamClient.EVENT_LOGGED_ON, self.login_success)
         self._steamClient.on(SteamClient.EVENT_CHANNEL_SECURED, self.login_secured)
         self._steamClient.on(SteamClient.EVENT_ERROR, self.login_error)
         self._steamClient.on(SteamClient.EVENT_CONNECTED, self.connected)
         self._steamClient.on(SteamClient.EVENT_DISCONNECTED, self.disconnected)
         self._steamClient.on(SteamClient.EVENT_NEW_LOGIN_KEY, self.new_login_key)
         # Bind EndPoints
         RyderClient().addEndPoint('on_connect', self._run)
         RyderClient().addEndPoint('steamLogin', self._steamLoginData)
         RyderClient().addEndPoint('steam2fa',self._steam2faData)
Beispiel #9
0
 def _run(self):
     # Start Login Sequence
     if not self._running:
         self._running = True
         self._steamClient.set_credential_location(self._cache)
         if os.path.exists(self._cache + 'steam.txt'):
             f = open(self._cache + 'steam.txt', 'r')
             data = f.readlines()
             f.close()
             gevent.spawn_later(2, SteamClient.login, self._steamClient, username=data[0].replace('\n',''), login_key=data[1])
         else:
             if self._notification != None:
                 self._notification('Steam', 'Login', 'Requesting Login Data')
             RyderClient().send("[\"steamLogin\"]")
 def _run(self):
     # Start Login Sequence
     if not self._running:
         self._running = True
         self.loop.create_task(self._loop())
         if os.path.exists(self._cache + 'discord.txt'):
             f = open(self._cache + 'discord.txt', 'r')
             data = f.readlines()
             f.close()
             gevent.spawn_later(2, discord.Client.run, self, data[0])
         else:
             if self._notification != None:
                 self._notification('Discord', 'Login',
                                    'Requesting Login Data')
             RyderClient().send("[\"discordLogin\"]")
Beispiel #11
0
 def _newProcessName(self, data):
     if data[1] != self._currentProgram:
         if data[1] is None:
             self._currentProgram = None
             self._label.setPixmap(QPixmap())
             self._label.update()
         else:
             if not os.path.exists(self._iconsPath + data[1] + '.png'):
                 # Request icon if not in cache
                 RyderClient().send("[\"foregroundProcessIcon\"]")
             else:
                 self._currentProgram = data[1]
                 # Load from cache
                 pixmap = QPixmap()
                 pixmap.load(self._iconsPath + self._currentProgram +
                             '.png')
                 self._label.setPixmap(pixmap)
                 self._label.update()
Beispiel #12
0
 def _onConnect(self):
     RyderClient().send("[\"foregroundProcessName\"]")
Beispiel #13
0
 def __init__(self):
     self.brightness = 100
     # Bind Server
     RyderClient().addEndPoint('on_connect', self._onConnect)
     RyderClient().addEndPoint('monitorBrightness', self._newMonitorBrightness)
Beispiel #14
0
 def _requestNewAppLauncherData(self, data):
     RyderClient().send("[\"appLauncher\"]")
Beispiel #15
0
 def auth_code_prompt(self, is2fa, code_mismatch):
     print("Steam2FA Required")
     if self._notification != None:
         self._notification('Steam', 'Login', 'Requesting 2 Factor Authentication')
     RyderClient().send("[\"steam2fa\"]")
Beispiel #16
0
 def onClick(self, i: int):
     print("Request Power Plan: " + self._plans[i])
     RyderClient().send("[\"powerPlan\",\"" + self._plans[i] + "\"]")
     self.close()
Beispiel #17
0
 def onClick(self, i: int):
     RyderClient().send("[\"launchApp\"," + str(i) + "]")
Beispiel #18
0
 def _onConnect(self):
     RyderClient().send("[\"appLauncher\"]")
Beispiel #19
0
 def setBrightness(self, value):
     RyderClient().send("[\"setMonitorBrightness\"," + str(value) + "]")
     self.brightness = value
    def prepare(path: str, ui_file: str = None, preloadedSettings=None):
        # Open settings and ui files
        if preloadedSettings == None:
            file = open(path + '/settings.json', 'r')
            settings = json.loads(file.read())
            file.close()
        else:
            settings = preloadedSettings
        if ui_file == None:
            ui_file = settings['ui'][
                'initial_page'] if 'initial_page' in settings[
                    'ui'] else 'ui.json'
        file = open(path + '/' + ui_file, 'r')
        ui = json.loads(file.read())
        file.close()
        # Fill in variables in ui file
        ## UI section
        pos = ui['ui'][0]['geometry'][0:2].copy()
        new_pos = pos.copy()
        for entry in ui['ui']:
            # Positioning
            if 'geometry' in entry:
                update_pos = [True, True]
                for i in range(2):
                    if isinstance(entry['geometry'][i], str):
                        if entry['geometry'][i][0] != "d":
                            new_pos[i] = pos[i] + int(entry['geometry'][i])
                        else:
                            update_pos[i] = False
                            if len(entry['geometry'][i]) > 1:
                                new_pos[i] = pos[i] + int(
                                    entry['geometry'][i][1:])
                            else:
                                new_pos[i] = pos[i]
                    else:
                        new_pos[i] = entry['geometry'][i]
                entry['geometry'][0:2] = new_pos.copy()

                if update_pos[0]:
                    pos[0] = new_pos[0]
                if update_pos[1]:
                    pos[1] = new_pos[1]
            # Fill in variables
            if entry['type'] == 'StaticLabel':
                # Check if label message is tied to variable in settings
                entry['text'] = ConfigurationParser._concatTextWithVariables(
                    entry['text'], settings['ui']['variables'])
            elif (entry['type'] == 'DynamicLabel'
                  or entry['type'] == 'ProgressBar'
                  or entry['type'] == 'RoundProgressBar'
                  or entry['type'] == 'CornerProgressBar'):
                # Ensure element has bounds entry (This is optional for DynamicLabel)
                if 'bounds' in entry['metric']:
                    for i in range(2):
                        entry['metric']['bounds'][
                            i] = ConfigurationParser._fillFieldFormula(
                                entry['metric']['bounds'][i],
                                settings['ui']['variables'])
            elif entry['type'] == 'Graph':
                if 'bounds' in entry['metric']:
                    for i in range(2):
                        # Check if bound is a list (if it is it means we have a dynamic bound with a limit)
                        if isinstance(entry['metric']['bounds'][i], list):
                            entry['metric']['bounds'][i][
                                1] = ConfigurationParser._fillFieldFormula(
                                    entry['metric']['bounds'][i][1],
                                    settings['ui']['variables'])
                        # Check if bound is a formula
                        elif isinstance(entry['metric']['bounds'][i], str):
                            # Ensure we are looking at a formula and not dynamic bound without a limit
                            if entry['metric']['bounds'][i] != 'dynamic':
                                entry['metric']['bounds'][
                                    i] = ConfigurationParser._fillFieldFormula(
                                        entry['metric']['bounds'][i],
                                        settings['ui']['variables'])
        ## Unit converters section
        if 'unit_converters' in ui:
            for entry in ui['unit_converters']:
                entry = ui['unit_converters'][entry]
                entry['divisor'] = ConfigurationParser._fillFieldFormula(
                    entry['divisor'], settings['ui']['variables'])
                if isinstance(entry['unit'], list):
                    for index in range(len(entry['unit'])):
                        entry['unit'][
                            index] = ConfigurationParser._concatTextWithVariables(
                                entry['unit'][index],
                                settings['ui']['variables'])
                else:
                    entry[
                        'unit'] = ConfigurationParser._concatTextWithVariables(
                            entry['unit'], settings['ui']['variables'])
        # Initialization
        if preloadedSettings == None:
            if 'additional_metrics' in settings['services']['data_provider']:
                InternalMetrics().setSettings(
                    settings['services']['data_provider']
                    ['additional_metrics'],
                    settings['services']['data_provider']['log_n_samples'])
            RyderClient().setup(
                settings['services']['data_provider']['ip'],
                settings['services']['data_provider']['port'],
                settings['services']['data_provider']['password'])
            if 'hyperion' in settings['services']:
                Hyperion().setUrl(settings['services']['hyperion']['ip'],
                                  settings['services']['hyperion']['port'])
                Hyperion().getState()
        Monitor()

        return settings['ui']['fps'], ui, settings, ui_file
Beispiel #21
0
 def __init__(self, window):
     self._window = window
     RyderClient().addEndPoint('status', self._newStatus)
Beispiel #22
0
 def _onConnect(self):
     RyderClient().send("[\"getMonitorBrightness\"]")