I tried to write a script like this suggestion:
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?