def main(): """ Main entry point of the app """ read_args() # ------------------------------------------------------------------------- # COLORS color = set_color(args.color) # ------------------------------------------------------------------------- # DEVICES # Create a DeviceManager. This is used to get specific devices device_manager = DeviceManager() if (args.list_devices or args.list_devices_long): list_devices(device_manager) # Disable daemon effect syncing. # Without this, the daemon will try to set the lighting effect to every device. # TODO: Could be enabled as flag device_manager.sync_effects = False # Do below only if dry run is not specified if args.automatic or args.effect or args.color: set_effect_to_all_devices(device_manager, args.effect, color) if args.dpi: set_dpi(device_manager)
def get_device(): try: return next( filter(lambda x: x._type == 'keyboard', DeviceManager().devices)) except StopIteration as e: raise NoDeviceFoundError('ERROR: No razer device found') from e
def find_keyboard(self): device_manager = DeviceManager() device_manager.sync_effects = False for device in device_manager.devices: if device.name == self.name: return device raise ValueError('Keyboard `{}` does not exist'.format(self.name))
def main(): device_manager = DeviceManager() devices = device_manager.devices for device in devices: if not device.fx.advanced: print("Skipping device " + device.name + " (" + device.serial + ")") devices.remove(device) # Disable daemon effect syncing. # Without this, the daemon will try to set the lighting effect to every device. device_manager.sync_effects = False # Use last device found since that's all I have and use on my system... device.fx.advanced.matrix.reset() device.fx.advanced.draw() # Limit snake game to main portion of keyboard snek = Snek(1, 2, device.fx.advanced.rows - 2, device.fx.advanced.cols - 6) while True: # Draw snek head_and_tail = snek.get_snek() apple_x, apple_y = snek.get_apple() device.fx.advanced.matrix.reset() count = 0 for x, y in head_and_tail: if 0 == count: device.fx.advanced.matrix[x, y] = (255, 255, 0) else: device.fx.advanced.matrix[x, y] = (0, 255 / count, 0) count += 1 device.fx.advanced.matrix[apple_x, apple_y] = (255, 0, 0) device.fx.advanced.draw() time.sleep(1 / snek.get_score()) # Randomly change dir snek.set_smart_dir() res = snek.incr() if res < 0: time.sleep(snek.get_score()) device.fx.wave(razer_constants.WAVE_RIGHT) time.sleep(snek.get_score()) del snek snek = Snek(1, 2, device.fx.advanced.rows - 2, device.fx.advanced.cols - 6) elif res > 0: device.fx.static(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) time.sleep(0.750) device.fx.static(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) time.sleep(0.750)
def main() -> None: """ Main entry point of the app """ args = read_args(sys.argv[1:]) if args.manual is not None: return util.print_manual(args.manual) # Create a DeviceManager. This is used to get specific devices device_manager = DeviceManager() rc = RazerCli.init_create(device_manager, args, __version__) rc.run()
def api_factory() -> Any: api = None try: from openrazer.client import DeviceManager, DaemonNotFound try: api = DeviceManager() api.sync_effects = True except DaemonNotFound: sys.exit(wording.get('daemon_no').format('RAZER CHROMA') + wording.get('exclamation_mark')) return api except ImportError: sys.exit(wording.get('package_no').format('OPENRAZER META') + wording.get('exclamation_mark'))
def get_devices(filter_advanced=True): device_manager = DeviceManager() devices = [] for d in device_manager.devices: if d.fx.advanced: print("Found device %s" % d.name) devices.append(d) print("Found {} Razer devices".format(len(devices))) # Set this to false or daemon will try to set the effects to all devices device_manager.sync_effects = False return devices
from collections import defaultdict import colorsys import random import time import threading from openrazer.client import DeviceManager from openrazer.client import constants as razer_constants # Create a DeviceManager. This is used to get specific devices device_manager = DeviceManager() print("Found {} Razer devices".format(len(device_manager.devices))) devices = device_manager.devices for device in devices: if not device.fx.advanced: print("Skipping device " + device.name + " (" + device.serial + ")") devices.remove(device) print() # Disable daemon effect syncing. # Without this, the daemon will try to set the lighting effect to every device. device_manager.sync_effects = False # Helper function to generate interesting colors def random_color(): rgb = colorsys.hsv_to_rgb(random.uniform(0, 1), random.uniform(0.5, 1), 1)
import sys from openrazer.client import DeviceManager from openrazer.client import constants as razer_constants dm = DeviceManager() dm.sync_effects = False for dv in dm.devices: if sys.argv[1] == "lock": dv.fx.starlight_random(razer_constants.STARLIGHT_SLOW) else: dv.fx.reactive(255, 0, 0, razer_constants.REACTIVE_1000MS)
settings = [i for i in settings if len(i) > 0] settings = {i.split(" = ")[0]: i.split(" = ")[1] for i in settings} quit = False ledBases = {} basehue = float(settings["basehue"]) maxHue = float(settings["maxhue"]) colorStep = float(settings["colorstep"]) backStep = float(settings["colorbackstep"]) isRev = bool(distutils.strtobool(settings["backwards"])) doWorkspace = bool(distutils.strtobool(settings["showWorkspace"])) doReset = bool(distutils.strtobool(settings["doResetOnScriptChange"])) doVM = bool(distutils.strtobool(settings["checkVM"])) speed = float(settings["speed"]) watchConfig = bool(distutils.strtobool(settings["watchConfig"])) devices = [i for i in DeviceManager().devices if i is not i.type == "keyboard"] mouse = rivalcfg.get_first_mouse() rows = { 1: [0, 1, 2, 3, 4, 5], 2: [1, 2, 3, 4, 5], 3: [0, 1, 2, 3, 4, 5], 4: [0, 1, 2, 3, 4, 5], 5: [0, 1, 2, 3, 4, 5], 6: [0, 1, 2, 3, 4, 5], 7: [0, 1, 2, 3, 4, 5], 8: [0, 1, 2, 3, 4, 5], 20: [0], 9: [0, 1, 2, 3, 4, 5], 10: [0, 1, 2, 3, 4, 5], 11: [0, 1, 2, 3, 4, 5], 12: [0, 1, 2, 3, 4, 5],