Esempio n. 1
0
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)
Esempio n. 2
0
    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))
Esempio n. 3
0
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)
Esempio n. 4
0
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'))
Esempio n. 5
0
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
# 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)
    return tuple(map(lambda x: int(256 * x), rgb))


# Handle the startlight effect for a single key
def starlight_key(device, row, col, active):
    color = random_color()

    hue = random.uniform(0, 1)
    start_time = time.time()
Esempio n. 7
0
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)))
print()

# Disable daemon effect syncing.
# Without this, the daemon will try to set the lighting effect to every device.
device_manager.sync_effects = False

# Iterate over each device and set the wave effect
for device in device_manager.devices:
    print("Setting {} to wave".format(device.name))

    # Set the effect to wave.
    # wave requires a direction, but different effect have different arguments.
    device.fx.wave(razer_constants.WAVE_LEFT)
Esempio n. 8
0
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)