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?


Use acpi:

The event is handled by acpi:

$ sudo nano /etc/acpi/handler.sh

I did something like this:

        case "$3" in
                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.