Skip to content

Instantly share code, notes, and snippets.

@nikolaybotev
Last active November 27, 2023 19:58
Show Gist options
  • Save nikolaybotev/62e4d656f96aa2edec944f4c050e1184 to your computer and use it in GitHub Desktop.
Save nikolaybotev/62e4d656f96aa2edec944f4c050e1184 to your computer and use it in GitHub Desktop.
systemd service to turn off Raspberry Pi LEDs on startup.
[Unit]
Description=Turn Off LED %i
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c 'echo 0 > /sys/class/leds/%i/brightness'
ExecStop=/bin/sh -c 'echo 255 > /sys/class/leds/%i/brightness'
[Install]
WantedBy=default.target
@nikolaybotev
Copy link
Author

nikolaybotev commented Jun 17, 2021

Quick Setup

sudo wget -P /etc/systemd/system https://gist.githubusercontent.com/nikolaybotev/62e4d656f96aa2edec944f4c050e1184/raw/a5f00223242fb68740ad7a656388e45f1f156be2/turn-off-led@.service

sudo systemctl daemon-reload

sudo systemctl enable turn-off-led@PWR.service
sudo systemctl enable turn-off-led@ACT.service

sudo systemctl start turn-off-led@PWR.service
sudo systemctl start turn-off-led@ACT.service
  • Updated for the latest version of Raspberry Pi OS on November 27, 2023. Replace PWR and ACT in the commands above with led0 and led1 if you are running an older versions of Raspberry Pi OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment