initial commit
This commit is contained in:
219
etherlight.py
Executable file
219
etherlight.py
Executable file
@@ -0,0 +1,219 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from rgbw_colorspace_converter.colors.converters import RGB
|
||||||
|
|
||||||
|
LESBIAN_PRIDE_SINOPIA = [214, 41, 0]
|
||||||
|
LESBIAN_PRIDE_ATOMIC_TANGERINE = [255, 155, 85]
|
||||||
|
LESBIAN_PRIDE_WHITE = [255, 255, 255]
|
||||||
|
LESBIAN_PRIDE_SUPER_PINK = [212, 97, 166]
|
||||||
|
LESBIAN_PRIDE_FLIRT = [165, 0, 98]
|
||||||
|
|
||||||
|
LGBTQ_PRIDE_RED = [255, 0, 24]
|
||||||
|
LGBTQ_PRIDE_ORANGE = [255, 165, 44]
|
||||||
|
LGBTQ_PRIDE_YELLOW = [255, 255, 65]
|
||||||
|
LGBTQ_PRIDE_GREEN = [0, 128, 24]
|
||||||
|
LGBTQ_PRIDE_BLUE = [0, 0, 249]
|
||||||
|
LGBTQ_PRIDE_PURPLE = [134, 0, 125]
|
||||||
|
|
||||||
|
TRANS_PRIDE_MAYA_BLUE = [85, 205, 252]
|
||||||
|
TRANS_PRIDE_WHITE = [255, 255, 255]
|
||||||
|
TRANS_PRIDE_AMARANTH_PINK = [247, 168, 184]
|
||||||
|
|
||||||
|
BISEXUAL_PRIDE_ROYAL_RED = [208, 0, 112]
|
||||||
|
BISEXUAL_PRIDE_CADMIUM_VIOLET = [140, 71, 153]
|
||||||
|
BISEXULA_PRIDE_DARK_POWDER_BLUE = [0, 50, 160]
|
||||||
|
|
||||||
|
PANSEXUAL_PRIDE_PHILIPPINE_PINK = [255, 27, 141]
|
||||||
|
PANSEXUAL_PRIDE_SIZZLING_SUNRISE = [255, 218, 0]
|
||||||
|
PANSEXUAL_PRIDE_SPIRO_DISCO_BALL = [27, 179, 255]
|
||||||
|
|
||||||
|
|
||||||
|
def template_pansexual():
|
||||||
|
|
||||||
|
command = ""
|
||||||
|
|
||||||
|
for port in range(1, 19):
|
||||||
|
if port < 7:
|
||||||
|
color = RGB(*PANSEXUAL_PRIDE_PHILIPPINE_PINK)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 13:
|
||||||
|
color = RGB(*PANSEXUAL_PRIDE_SIZZLING_SUNRISE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
else:
|
||||||
|
color = RGB(*PANSEXUAL_PRIDE_SPIRO_DISCO_BALL)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
def template_bisexual():
|
||||||
|
|
||||||
|
command = ""
|
||||||
|
|
||||||
|
for port in range(1, 19):
|
||||||
|
if port < 8:
|
||||||
|
color = RGB(*BISEXUAL_PRIDE_ROYAL_RED)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 12:
|
||||||
|
color = RGB(*BISEXUAL_PRIDE_CADMIUM_VIOLET)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
else:
|
||||||
|
color = RGB(*BISEXULA_PRIDE_DARK_POWDER_BLUE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
def template_trans():
|
||||||
|
|
||||||
|
command = ""
|
||||||
|
|
||||||
|
for port in range(1, 19):
|
||||||
|
if port < 5:
|
||||||
|
color = RGB(*TRANS_PRIDE_MAYA_BLUE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 8:
|
||||||
|
color = RGB(*TRANS_PRIDE_AMARANTH_PINK)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 12:
|
||||||
|
color = RGB(*TRANS_PRIDE_WHITE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 15:
|
||||||
|
color = RGB(*TRANS_PRIDE_AMARANTH_PINK)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
else:
|
||||||
|
color = RGB(*TRANS_PRIDE_MAYA_BLUE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
def template_lesbian():
|
||||||
|
|
||||||
|
command = ""
|
||||||
|
|
||||||
|
for port in range(1, 19):
|
||||||
|
if port < 5:
|
||||||
|
color = RGB(*LESBIAN_PRIDE_SINOPIA)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 8:
|
||||||
|
color = RGB(*LESBIAN_PRIDE_ATOMIC_TANGERINE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 12:
|
||||||
|
color = RGB(*LESBIAN_PRIDE_WHITE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 15:
|
||||||
|
color = RGB(*LESBIAN_PRIDE_SUPER_PINK)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
else:
|
||||||
|
color = RGB(*LESBIAN_PRIDE_FLIRT)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
def template_lgbtq():
|
||||||
|
|
||||||
|
command = ""
|
||||||
|
|
||||||
|
for port in range(1, 19):
|
||||||
|
if port < 4:
|
||||||
|
color = RGB(*LGBTQ_PRIDE_RED)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 7:
|
||||||
|
color = RGB(*LGBTQ_PRIDE_ORANGE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 10:
|
||||||
|
color = RGB(*LGBTQ_PRIDE_YELLOW)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 13:
|
||||||
|
color = RGB(*LGBTQ_PRIDE_GREEN)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
elif port < 16:
|
||||||
|
color = RGB(*LGBTQ_PRIDE_BLUE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
else:
|
||||||
|
color = RGB(*LGBTQ_PRIDE_PURPLE)
|
||||||
|
command += get_color_commands(port, *color.rgbw)
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
def get_color_commands(port, red, green, blue, white):
|
||||||
|
command = ""
|
||||||
|
command += "echo {} r {} > /proc/led/led_color; ".format(port, red * 64)
|
||||||
|
command += "echo {} g {} > /proc/led/led_color; ".format(port, green * 64)
|
||||||
|
command += "echo {} b {} > /proc/led/led_color; ".format(port, blue * 64)
|
||||||
|
command += "echo {} w {} > /proc/led/led_color; ".format(port, white * 64)
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
def flush_leds():
|
||||||
|
command = "echo 0 > /proc/led/led_mode"
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
def get_port_color(port, red, green, blue):
|
||||||
|
color = RGB(red, green, blue)
|
||||||
|
command = get_color_commands(port, *color.rgbw)
|
||||||
|
|
||||||
|
return command
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="Etherlight",
|
||||||
|
description="Little tool to set the LEDs on Unifi devices with Etherlight support",
|
||||||
|
)
|
||||||
|
group = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
parser.add_argument(
|
||||||
|
"device", help="The device you want to connect to via SSH (ssh_config works)"
|
||||||
|
)
|
||||||
|
group.add_argument(
|
||||||
|
"-f",
|
||||||
|
"--flush",
|
||||||
|
help="Clears the LEDs on the device (turns them off)",
|
||||||
|
action="store_true",
|
||||||
|
)
|
||||||
|
group.add_argument(
|
||||||
|
"-t",
|
||||||
|
"--template",
|
||||||
|
help="sets a predefined template. Valid options are LESBIAN or LGBTQ",
|
||||||
|
choices=["lesbian", "lgbtq", "trans", "bisexual", "pansexual"],
|
||||||
|
)
|
||||||
|
group.add_argument(
|
||||||
|
"-c",
|
||||||
|
"--color",
|
||||||
|
help="Sets a RGB value to a specified port. This parameter needs 4 inputs: port, red, green, blue",
|
||||||
|
nargs=4,
|
||||||
|
type=int,
|
||||||
|
metavar=("PORT", "RED", "GREEN", "BLUE"),
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.flush:
|
||||||
|
command = flush_leds()
|
||||||
|
if args.color:
|
||||||
|
command = get_port_color(*args.color)
|
||||||
|
if args.template:
|
||||||
|
match args.template:
|
||||||
|
case "lesbian":
|
||||||
|
command = template_lesbian()
|
||||||
|
case "lgbtq":
|
||||||
|
command = template_lgbtq()
|
||||||
|
case "trans":
|
||||||
|
command = template_trans()
|
||||||
|
case "bisexual":
|
||||||
|
command = template_bisexual()
|
||||||
|
case "pansexual":
|
||||||
|
command = template_pansexual()
|
||||||
|
|
||||||
|
#print(command)
|
||||||
|
subprocess.run(["/usr/bin/ssh", args.device, command])
|
||||||
13
etherlight_pride_demo.sh
Executable file
13
etherlight_pride_demo.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
./etherlight.py usw-livingroom -f
|
||||||
|
sleep 3
|
||||||
|
./etherlight.py usw-livingroom -t lgbtq
|
||||||
|
sleep 3
|
||||||
|
./etherlight.py usw-livingroom -t bisexual
|
||||||
|
sleep 3
|
||||||
|
./etherlight.py usw-livingroom -t lesbian
|
||||||
|
sleep 3
|
||||||
|
./etherlight.py usw-livingroom -t pansexual
|
||||||
|
sleep 3
|
||||||
|
./etherlight.py usw-livingroom -t trans
|
||||||
Reference in New Issue
Block a user