8

Now I have two scripts and I want to execute them respectively when I close the laptop lip and open it. How can I do this?

7
2

Use acpi:

The event is handled by acpi:

$ sudo nano /etc/acpi/handler.sh

I did something like this:


    button/lid)
        case "$3" in
            close)
                logger 'LID closed'
        USER=$(ps -C i3 -o user=)
        if test $USER; then DISPLAY=:0.0 su $USER -c "/usr/bin/i3lock -i /usr/share/pixmaps/Screensaver.png"; fi
                ;;

Automatically starts i3lock when i close my lid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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