visualizer improvments
This commit is contained in:
parent
2bb8739b38
commit
3dde78fbae
@ -37,18 +37,28 @@ def helpmenu():
|
||||
print("-s <hex-color> set static color")
|
||||
print("-v visualizer")
|
||||
|
||||
def base_color(r,g,b):
|
||||
min_value = min([r,g,b])
|
||||
return r//min_value, g//min_value, b//min_value
|
||||
|
||||
def visualizer(color):
|
||||
r,g,b = hex_to_rgb(color)
|
||||
r_base,g_base,b_base = base_color(r,g,b)
|
||||
cava = subprocess.Popen(["cava", "-p", "/etc/lc/cava.conf"], stdout=subprocess.PIPE)
|
||||
sed = subprocess.Popen(["sed", "-u", "s/;.*;$//"], stdin=cava.stdout, stdout=subprocess.PIPE)
|
||||
#subprocess.Popen([sys.argv[0]], stdin=sed.stdout, shell=False)
|
||||
for line in sed.stdout:
|
||||
line = int(line)
|
||||
r,g,b = hex_to_rgb(color)
|
||||
r = int(r*(line/1000))
|
||||
g = int(g*(line/1000))
|
||||
b = int(b*(line/1000))
|
||||
hex_color = rgb_to_hex(r,g,b)
|
||||
print(r,g,b)
|
||||
r_out = int(r*(line/1000))
|
||||
g_out = int(g*(line/1000))
|
||||
b_out = int(b*(line/1000))
|
||||
# print(line, ',', r_out,g_out,b_out, ' | ', r,g,b)
|
||||
print(r_out,g_out,b_out)
|
||||
if r_out < r_base or g_out < g_base or b_out < b_base:
|
||||
r_out = r_base
|
||||
g_out = g_base
|
||||
b_out = b_base
|
||||
hex_color = rgb_to_hex(r_out,g_out,b_out)
|
||||
send(hex_color)
|
||||
cava.stdout.close()
|
||||
sed.stdout.close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user