0

At night my study lights up like a Christmas tree.

I wanted a script to turn the PWR LED off but the commands have changed over time.

How can I turn the PWR LED off?

1 Answer 1

0

There are many other answers and different methods of controlling the PWR LED.

I developed the following (which I intend to use with cron to control lights on a timer) but can be run from command line (for a user with sudo privileges).

This has been tested on many Pi (from Pi B+ to Pi4) running Stretch and Bullseye

#!/bin/bash
# script to turn PWR LED ON/OFF
# PWRLED or PWRLED OFF turns LED off
# PWRLED anything turns LED ON
# 2023-05-06

ONOFF="$1"
if [ "${ONOFF}" = "" ]; then
ONOFF="0"
else 
if [ "${ONOFF}" = "OFF" ]; then
ONOFF="0"
else 
ONOFF="255"
fi
fi

if [ -e /sys/devices/platform/leds/leds/PWR ]; then
echo $ONOFF | sudo tee /sys/devices/platform/leds/leds/PWR/brightness  > /dev/null
else    # for older OS without leds/PWR
echo $ONOFF | sudo tee /sys/devices/platform/leds/leds/led1/brightness  > /dev/null
fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.