10

I tried to write a script like this suggestion:

How do I configure the screen to lock when I close the lid?

I created a directory and a new script file:

mkdir /etc/acpi/local
gksudo gedit /etc/acpi/local/lid.sh.post

The file /etc/acpi/local/lid.sh.post with the following code:

#!/bin/sh

#########################################################################
## Script written by Ruben Barkow                                      ##
## https://gist.githubusercontent.com/rubo77/1a3320fda5a47fdebde7/raw/87cde3f0554467a132aba3cda7ad3c5e7187571f/lid.sh.post
## Description: This script reacts if laptop lid is opened or          ##
## closed in Ubuntu 11.10 (Oneiric Ocelot).                            ##
##                                                                     ##
## This script can be freely redistributed, modified and used.         ##
## Any redistribution must include the information of authors.         ##
##                                                                     ##
## THIS SCRIPT HAS NO WARRANTY!                                        ##
#########################################################################

grep -q close /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
    echo close>>/tmp/screen.lid
fi
grep -q open /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
    echo open>>/tmp/screen.lid
fi

I tried to get this running in Ubuntu 14.04, but why this has no effect.

Is there a new way in Ubuntu 14.04 to catch the lid close and open events?

1

1 Answer 1

15

I got a hint here: https://askubuntu.com/a/518825/34298

  • The script you want to call when the lid opens or closes has to be stored
    in /etc/acpi/lid.sh.

  • Then there has to be created the correct file /etc/acpi/events/lm_lid with the content as follows:

     event=button/lid.*
     action=/etc/acpi/lid.sh
    
  • Reboot your system to let this take effect. Or maybe it is enough to restart your ACPI using

     sudo systemctl restart acpid.service 
    
1
  • 2
    Restarting ACPI without rebooting works for me! May 22, 2017 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .