Last active
March 18, 2020 12:45
-
-
Save indeedwatson/8cef824a5ff325812cb5dd06de77f417 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
import sys | |
import subprocess | |
from os import listdir | |
LEDPath = "/sys/class/hidraw/hidraw2/device/leds/" | |
def getLEDColorID(): | |
""" | |
Store color and global IDs of LED in a dictionary with the full path. | |
The format is dddd:dddd:dddd:string, but the digits can change on reboot. | |
""" | |
LEDs = {} | |
for i in listdir(LEDPath): | |
LEDName = i.split(":")[-1] | |
LEDs[LEDName] = f"{LEDPath}/{i}" | |
return LEDs | |
def setBrightness(LEDs: dict, | |
globalLED: int=1, | |
R: int=1, | |
B: int=1, | |
G: int=1): | |
with open(f"{LEDs['red']}/brightness") as file: | |
file.write(str(R)) | |
def main(): | |
LEDs = getLEDColorID() | |
print(LEDs) | |
setBrightness(LEDs, 0, 100, 0, 0) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment