-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorbs-json.py
More file actions
68 lines (49 loc) · 1.54 KB
/
Copy pathorbs-json.py
File metadata and controls
68 lines (49 loc) · 1.54 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import json
import os
import random
import threading
import subprocess
import openrazer.client
#Time In Seconds ex. 300 = 5min, 120 = 2min, 60=1min
time = 10
themesFile = "./scripts/themes.json"
def getBackground():
with open(themesFile) as json_file:
json_data = json.load(json_file)
count = len(json_data)
count2 = count - 1
ranNum = random.randint(0,count2)
print("random number: " + str(ranNum))
theme = json_data[str(ranNum)]
return theme
def setBackground(background):
backgroundFile = background
print("changing background to - " + backgroundFile)
subprocess.call("gsettings set org.gnome.desktop.background picture-uri file://{0}".format(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
rgbStrip = rgb.lstrip('#')
color = tuple(int(rgbStrip[i:i+2], 16) for i in (0, 2, 4))
#print info
print("Setting {} to {}".format(device.name,color))
# Set the effect
device.fx.static(color[0],color[1],color[2])
device.brightness = 100
def setAll():
print("-")
background = getBackground()
path = background['path']
color = background['rgb']
print("hex: " + color)
#print(path)
setBackground(path)
setlightColor(color)
print("-")
def run():
threading.Timer(time, run).start()
setAll()
#Run the program
run()