Xubuntu ACPI: The Lid

January 19, 2007 at 1:03 am 4 comments

So what exactly does Xubuntu do when you close your laptop lid? acpid parses all the files in /etc/acpi/events for every file looking for an event= line that contains something that matches button/lid LID 00000080 00000005 or any part of it. On Xubuntu this would be /etc/acpi/events/lidbtn which calles /etc/acpi/lid.sh to handle this event.

So what exactly does /etc/acpi/lid.sh do? (The rest of this post goes line by line through /etc/acpi/lid.sh in chunks and explains what’s going on. Code from the script should be in mono spaced font and blockquoted.)

. /usr/share/acpi-support/power-funcs
. /usr/share/acpi-support/policy-funcs
. /etc/default/acpi-support

These lines load some scripts containing utilities functions.

  • . /usr/share/acpi-support/power-funcs – functions to get misc state info
  • . /usr/share/acpi-support/policy-funcs – checks for GNOME/KDE power management programs
  • . /etc/default/acpi-support – power conf file

[ -x /etc/acpi/local/lid.sh.pre ] && /etc/acpi/local/lid.sh.pre

This line looks for the executable file /etc/acpi/local/lid.sh.pre and runs the script if found. I assume this script is for personal user actions to be done before everything else since it does not exist by default.

if [ `CheckPolicy` == 0 ]; then exit; fi

This line checks for GNOME or KDE power managers running. If they are running the script trusts them take over and doesn’t do anything further.

grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]

If the word “closed” is in /proc/acpi/button/lid/*/state this means that the laptop is shut and needs to do the following.

    for x in /tmp/.X11-unix/*; do
        displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`

To be continued…

Entry filed under: Linux. Tags: , , , , , , .

Integrate Your Applications Clearing up the Ubuntu root Myth

4 Comments Add your own

  • 1. Michael  |  February 2, 2007 at 6:06 am

    Hey this is a great beginning. I was surprised about the lack of friendly power management tools in Xubuntu/Xfce but figured that meant I just have to learn more. I’m ready when you are!

    When I had a mac I was amazing at how it seemed to use zero power when the lid was closed. Getting my thinkpad to suspend will be a start.

  • 2. Mihai  |  March 16, 2007 at 6:22 pm

    Very very interesting

  • 3. Simon E.  |  February 18, 2008 at 7:46 pm

    So, what I’m taking away from this article is that I can edit /etc/default/acpi-support to change the lid close behavior in Xubuntu.

  • 4. dosnlinux  |  February 20, 2008 at 5:06 pm



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


%d bloggers like this: