-
Notifications
You must be signed in to change notification settings - Fork 0
/
orbs-cluster.py
71 lines (52 loc) · 1.73 KB
/
orbs-cluster.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import random
import threading
import subprocess
import openrazer.client
import colorsys
from colorz import colorz
#Path to pictures
path = "/home/cody/Pictures/Wallpapers"
#Time In Seconds ex. 300 = 5min, 120 = 2min, 60=1min
time = 30
def getBackground():
background = random.choice(os.listdir(path))
if os.path.isfile(os.path.join(path, background)) and background.lower().endswith(('.png', '.jpg', '.jpeg')):
return background
else:
print("Not Img File - Trying Again! Error File: " + background)
return getBackground()
def getColor(background):
backgroundFile = background
filePath = path + "/" + backgroundFile
for c in colorz(filePath, n=3):
cStrip = c.lstrip('#')
rgb = tuple(int(cStrip[i:i+2], 16) for i in (0, 2, 4))
return rgb
def setBackground(background):
backgroundFile = background
print("changing background to - " + backgroundFile)
subprocess.call("gsettings set org.gnome.desktop.background picture-uri file://{0}/{1}".format(path,backgroundFile), shell=True)
def setlightColor(rgb):
device_manager = openrazer.client.DeviceManager()
device_manager.sync_effects = False
for device in device_manager.devices:
#Get the Color
color = rgb
#print info
print("Setting {} to {},{},{}".format(device.name,color[0],color[1],color[2]))
# Set the effect
device.fx.static(color[0],color[1],color[2])
device.brightness = 100
def setAll():
print("-")
background = getBackground()
color = getColor(background)
setBackground(background)
setlightColor(color)
print("-")
def run():
threading.Timer(time, run).start()
setAll()
#Run the program
run()