Compare commits

..

2 Commits

Author SHA1 Message Date
m3philis
c09655c2ba flush LEDs before applying color/template to make sure the mode is set correctly even on new devices 2025-03-17 20:54:35 +01:00
m3philis
40bc3b09f2 add REQUIREMNTS.txt 2025-03-17 20:50:12 +01:00
2 changed files with 18 additions and 9 deletions

4
REQUIREMENTS.txt Normal file
View File

@@ -0,0 +1,4 @@
argcomplete
argparse
rgbw_colorspace_converter

View File

@@ -1,6 +1,7 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK
import argparse import argcomplete, argparse
import subprocess import subprocess
from rgbw_colorspace_converter.colors.converters import RGB from rgbw_colorspace_converter.colors.converters import RGB
@@ -33,7 +34,7 @@ PANSEXUAL_PRIDE_SPIRO_DISCO_BALL = [27, 179, 255]
def template_pansexual(): def template_pansexual():
command = "" command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19): for port in range(1, 19):
if port < 7: if port < 7:
@@ -51,7 +52,7 @@ def template_pansexual():
def template_bisexual(): def template_bisexual():
command = "" command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19): for port in range(1, 19):
if port < 8: if port < 8:
@@ -69,7 +70,7 @@ def template_bisexual():
def template_trans(): def template_trans():
command = "" command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19): for port in range(1, 19):
if port < 5: if port < 5:
@@ -93,7 +94,7 @@ def template_trans():
def template_lesbian(): def template_lesbian():
command = "" command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19): for port in range(1, 19):
if port < 5: if port < 5:
@@ -117,7 +118,7 @@ def template_lesbian():
def template_lgbtq(): def template_lgbtq():
command = "" command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19): for port in range(1, 19):
if port < 4: if port < 4:
@@ -143,6 +144,9 @@ def template_lgbtq():
def get_color_commands(port, red, green, blue, white): def get_color_commands(port, red, green, blue, white):
if args.color:
command = "echo 0 > /proc/led/led_mode;"
else:
command = "" command = ""
command += "echo {} r {} > /proc/led/led_color; ".format(port, red * 64) command += "echo {} r {} > /proc/led/led_color; ".format(port, red * 64)
command += "echo {} g {} > /proc/led/led_color; ".format(port, green * 64) command += "echo {} g {} > /proc/led/led_color; ".format(port, green * 64)
@@ -153,7 +157,7 @@ def get_color_commands(port, red, green, blue, white):
def flush_leds(): def flush_leds():
command = "echo 0 > /proc/led/led_mode" command = "echo 0 > /proc/led/led_mode;"
return command return command
@@ -184,7 +188,7 @@ if __name__ == "__main__":
group.add_argument( group.add_argument(
"-t", "-t",
"--template", "--template",
help="sets a predefined template. Valid options are LESBIAN or LGBTQ", help="Sets a predefined pride template.",
choices=["lesbian", "lgbtq", "trans", "bisexual", "pansexual"], choices=["lesbian", "lgbtq", "trans", "bisexual", "pansexual"],
) )
group.add_argument( group.add_argument(
@@ -196,6 +200,7 @@ if __name__ == "__main__":
metavar=("PORT", "RED", "GREEN", "BLUE"), metavar=("PORT", "RED", "GREEN", "BLUE"),
) )
argcomplete.autocomplete(parser)
args = parser.parse_args() args = parser.parse_args()
if args.flush: if args.flush: