Skip to content

Instantly share code, notes, and snippets.

@indeedwatson
Last active March 18, 2020 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indeedwatson/8cef824a5ff325812cb5dd06de77f417 to your computer and use it in GitHub Desktop.
Save indeedwatson/8cef824a5ff325812cb5dd06de77f417 to your computer and use it in GitHub Desktop.
#!/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