Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.world
linuxmint·Linux Mint!byDadifer

I made a script to turn off backlight when the lid closes for a 2017 MacBook Air running Cinnamon

  1. sudo apt update && sudo apt install acpid xdotool

  2. 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/).

  1. sudo chmod +x /etc/acpi/lid.sh

  2. sudo nano /etc/acpi/events/lid-button
    a. Write the following:
    event=button/lid.*
    action=/etc/acpi/lid.sh

  3. sudo systemctl restart acpid

  4. sudo nano /etc/systemd/logind.conf
    a. Delete the # from the line that says HandleLidSwitch=ignore
    b. Make sure the line ends in "ignore".

  5. sudo systemctl restart systemd-logind

Just wanted to document it because I didn't see a good rundown elsewhere.

View original on lemmy.world
4

3 replies

lemmy.world

Thanks for documenting it! Might be good to post this in the official Mint forum too?

2

You reached the end