-
Notifications
You must be signed in to change notification settings - Fork 2
/
disable_leds
executable file
·47 lines (36 loc) · 1.25 KB
/
disable_leds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -euo pipefail -o errtrace
CONFIG=/boot/config.txt
main(){
trap 'fail $? $LINENO' ERR
info "\\nDisabling raspberry pi LEDs..."
# https://www.jeffgeerling.com/blogs/jeff-geerling/controlling-pwr-act-leds-raspberry-pi
#
# Seems like the GH issue linked by the Jeff Geerling article has an update regarding
# disabling the power LED. It supercedes even some info in the JG article at time
# of writing.
#
# https://github.com/raspberrypi/firmware/issues/1742#issuecomment-1472359124
printf "\n# Disable the ACT LED.\ndtparam=act_led_trigger=none\ndtparam=act_led_activelow=off\n" | sudo tee --append $CONFIG >/dev/null
printf "\n# Disable the PWR LED.\ndtparam=pwr_led_trigger=none\n" | sudo tee --append $CONFIG >/dev/null
info "\\nDone, please reboot for the LEDs to be disabled."
}
fail(){
local exit_code=$1
local line_no=$2
local script_name
script_name=$(basename "${BASH_SOURCE[0]}")
die "Error in $script_name at line number: $line_no with exit code: $exit_code"
}
info(){
echo -e "\x1b[32m$*\x1b[0m" # green stdout
}
warn(){
echo -e "\x1b[33m$*\x1b[0m" # yellow stdout
}
die(){
echo
echo -e "\x1b[31m$*\x1b[0m" >&2 # red stderr
exit 1
}
main "$@"