-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrazerwal.py
More file actions
executable file
·41 lines (30 loc) · 1.11 KB
/
razerwal.py
File metadata and controls
executable file
·41 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3
import colorsys
import random
import time
import pywal
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()
# Wal stuff
def magic(s):
s = s.lstrip("#")
return tuple(int(s[i:i+2], 16) for i in (0, 2 ,4))
wal_colors = list(map(magic, list(pywal.colors.get(pywal.wallpaper.get(), 4)["colors"].values())))
# Disable daemon effect syncing.
# Without this, the daemon will try to set the lighting effect to every device.
device_manager.sync_effects = False
# Helper funciton to generate interesting colors
def random_color():
color = random.choice(wal_colors)
return color
# Set random colors for each zone of each device
for device in device_manager.devices:
rows, cols = device.fx.advanced.rows, device.fx.advanced.cols
for row in range(rows):
for col in range(cols):
device.fx.advanced.matrix[row, col] = random_color()
device.fx.advanced.draw()