reTerminal: Control LEDs as non-admin user

Is there any way to control the LEDs as a non-admin user? Currently, I can only do the following. I’ve only been able to get it to work by doing “sudo su”:

sudo su
cd /sys/class/leds/usr_led1/
echo 0 > brightness

The following does NOT work for some reason:

cd /sys/class/leds/usr_led1/
sudo echo 0 > brightness

Is there an alternate way to control the LEDs as a non-admin user, with a Python library maybe?

Looks like “brightness” is owned by the system user and other users only have read permission.

Since “brightness” is simply a file in these directories you can use chmod to grant write permission to everyone:

sudo chmod 746 brightness

Then the file will be writable by any user. A simple python program would be able to change the contents of the file to 0 or 1.

import time

led0 = open('/sys/class/leds/usr_led0/brightness','w')
while True:
	led0.write("1")
	led0.flush()
	time.sleep(0.5)
	led0.write("0")
	led0.flush()
	time.sleep(0.5)