I made a script to turn off backlight when the lid closes for a 2017 MacBook Air running Cinnamon
I made a script to turn off backlight when the lid closes for a 2017 MacBook Air running Cinnamon
- sudo apt update && sudo apt install acpid xdotool
- sudo nano /etc/acpi/lid.sh a. Copy and paste the following code into the file:
#!/bin/bash
Find the active screen backlight directory (usually intel_backlight or gmux_b>
BACKLIGHT_DIR=$(ls -d /sys/class/backlight/* | head -n 1)
if [ -z "$BACKLIGHT_DIR" ]; then exit 1 fi
Check if the lid is closed
if grep -q "closed" /proc/acpi/button/lid/*/state; then
4 cuts the power to the backlight completely
echo 4 > "$BACKLIGHT_DIR/bl_power" else
0 restores normal power to the backlight
echo 0 > "$BACKLIGHT_DIR/bl_power" fi
b. (Note: If your Mac names the lid something else, you can check it by running ls /proc/acpi/button/lid/).
- sudo chmod +x /etc/acpi/lid.sh
- sudo nano /etc/acpi/events/lid-button a. Write the following: event=button/lid.* action=/etc/acpi/lid.sh
- sudo systemctl restart acpid
- sudo nano /etc/systemd/logind.conf a. Delete the # from the line that says HandleLidSwitch=ignore b. Make sure the line ends in "ignore".
- sudo systemctl restart systemd-logind
Just wanted to document it because I didn't see a good rundown elsewhere.
Comments