<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thjaeger</id>
	<title>ThinkWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thjaeger"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/wiki/Special:Contributions/Thjaeger"/>
	<updated>2026-05-02T15:39:47Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.12</generator>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_configure_acpid&amp;diff=39951</id>
		<title>How to configure acpid</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_configure_acpid&amp;diff=39951"/>
		<updated>2008-11-24T09:12:04Z</updated>

		<summary type="html">&lt;p&gt;Thjaeger: /* Sources of Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
Basically, [[acpid]] just executes scripts residing in {{path|/etc/acpi/actions}}. Which script to launch at which event is configured in several files in {{path|/etc/acpi/events}}. All actions are documented in {{path|/var/log/acpid}} in older versions of acpid and to {{path|/var/log/messages}}, and {{path|/var/log/syslog}} via the syslog interface in newer versions &amp;gt;~1.0.6.&lt;br /&gt;
&lt;br /&gt;
==Sources of Information==&lt;br /&gt;
*{{cmduser|man acpid}} holds detailed information on how to configure acpid.&lt;br /&gt;
*The [[ibm-acpi]] package includes example scripts in the {{path|config}} folder inside the tarball. They are a good starting point to adjust them to your needs.&lt;br /&gt;
*You also might want to have a look at the [[Configs#ACPI | ACPI section of the Configs page]] or the [[:Category:Scripts|Scripts]] repository.&lt;br /&gt;
*And you can find information about the event strings [[ibm-acpi]] generates for certain keys at the [[How to get special keys to work#ibm-acpi_events | Special Keys HOWTO]].&lt;br /&gt;
*You can use acpi_listen to show acpi events&lt;br /&gt;
&lt;br /&gt;
==Example: go to sleep on lid close==&lt;br /&gt;
To make the ThinkPad go to sleep when you close the lid, you need to add&lt;br /&gt;
an event handler for the lid event and an action script that takes care&lt;br /&gt;
of going to sleep and resuming.&lt;br /&gt;
&lt;br /&gt;
===Event Script===&lt;br /&gt;
The event script needs to be created within {{path|/etc/acpi/events}} and can have any name you like.&lt;br /&gt;
In this case we call it lid because it will trigger the lid event. Do {{cmdroot|vi /etc/acpi/events/lid}} and make it look like this:&lt;br /&gt;
 event=button/lid&lt;br /&gt;
 action=/etc/acpi/actions/sleep.sh %e&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;event&amp;quot; line is a regular expression specifying the events we're&lt;br /&gt;
interested in. You can determine what the event strings are from looking at&lt;br /&gt;
{{path|/var/log/acpid}} after trying to suspend, close the lid, etc. .&lt;br /&gt;
You can find information about the event strings [[ibm-acpi]] generates for certain keys at the [[How to get special keys to work#ibm-acpi_events | Special Keys HOWTO]].&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;action&amp;quot; line is the command to be executed when these events are&lt;br /&gt;
dispatched. In this example we call the {{path|sleep.sh}} script residing in {{path|/etc/acpi/actions}} and pass the event description text using the %e placeholder.&lt;br /&gt;
&lt;br /&gt;
For the script you can use the &amp;lt;tt&amp;gt;hibernate&amp;lt;/tt&amp;gt; script of [http://www.tuxonice.net/ Tux On Ice] (it is independent of the [[ www.suspend2.net | suspend-to-disk]] functionality), or any of many examples available on the web, such as the one below.&lt;br /&gt;
&lt;br /&gt;
{{NOTE|To make your changes take effect after adding or modifying the events files you must do a &amp;lt;tt&amp;gt;kill -SIGHUP `pidof acpid`&amp;lt;/tt&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===Action Script===&lt;br /&gt;
Our example {{path|/etc/acpi/actions/sleep.sh}} script looks as follows:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 # if launched through a lid event and lid is open, do nothing&lt;br /&gt;
 echo &amp;quot;$1&amp;quot; | grep &amp;quot;button/lid&amp;quot; &amp;amp;&amp;amp; grep -q open /proc/acpi/button/lid/LID/state &amp;amp;&amp;amp; exit 0&lt;br /&gt;
 &lt;br /&gt;
 # remove USB 1.1 driver&lt;br /&gt;
 rmmod uhci_hcd&lt;br /&gt;
  &lt;br /&gt;
 # sync filesystem and clock&lt;br /&gt;
 sync&lt;br /&gt;
 /sbin/hwclock --systohc&lt;br /&gt;
 &lt;br /&gt;
 # switch to console&lt;br /&gt;
 FGCONSOLE=`fgconsole`&lt;br /&gt;
 chvt 6&lt;br /&gt;
 /usr/sbin/radeontool light off&lt;br /&gt;
 &lt;br /&gt;
 # go to sleep&lt;br /&gt;
 sleep 5 &amp;amp;&amp;amp; echo -n &amp;quot;mem&amp;quot; &amp;gt; /sys/power/state&lt;br /&gt;
 &lt;br /&gt;
 # readjust the clock (it might be off a bit after suspend)&lt;br /&gt;
 /sbin/hwclock --adjust&lt;br /&gt;
 /sbin/hwclock --hctosys&lt;br /&gt;
 &lt;br /&gt;
 # reload USB 1.1 driver&lt;br /&gt;
 modprobe uhci_hcd&lt;br /&gt;
 &lt;br /&gt;
 # turn on the backlight and switch back to X&lt;br /&gt;
 radeontool light on&lt;br /&gt;
 chvt $FGCONSOLE&lt;br /&gt;
&lt;br /&gt;
{{NOTE|This parts of this script are now part of some distributions, like Debian Etch and you probably don't need to add this script. Look into /etc/acpi/lid.sh, for example.}}&lt;br /&gt;
&lt;br /&gt;
====Explanations====&lt;br /&gt;
*The lid generates an event for both opening and closing thus requiring that we check its state and only act if it's closed.&lt;br /&gt;
*There have been problems encountered with the USB devices not working properly after a resume from suspend. To circumvent those we remove the USB driver prior to suspend and reload it afterwards.&lt;br /&gt;
*Note that the {{cmdroot|echo -n &amp;quot;mem&amp;quot; &amp;gt; /sys/power/state}} line does not return until we are revived. So there is only one event generated and there is no need to check the state of anything.&lt;br /&gt;
*The console switching code in this script is a special solution for [[Problem with LCD backlight remaining on during ACPI sleep|a problem where the backlight doesn't switch off]] on the {{T30}} and some other models. Before going to sleep, these models switch to console mode which causes the backlight to come back on. So we preemptively switch to console mode and turn off the backlight using [[radeontool]] before going to sleep.&lt;br /&gt;
&lt;br /&gt;
==Screen blanking script==&lt;br /&gt;
&lt;br /&gt;
You might want to be able to switch of the screen using Fn-f3.&lt;br /&gt;
This is not completely straightforward.&lt;br /&gt;
You will first  need to give permission to the script to muck around with your screen&lt;br /&gt;
&lt;br /&gt;
 xhost +local:root &lt;br /&gt;
&lt;br /&gt;
/etc/acpi/events/sleepbtn &lt;br /&gt;
contains&lt;br /&gt;
 event=(button[ /]sleep|ibm/hotkey HKEY 00000080 00001004)&lt;br /&gt;
 action=/etc/acpi/sleepbtn.sh&lt;br /&gt;
&lt;br /&gt;
And /etc/acpi/sleepbtn.sh is &lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 # simple script to turn the display on or off      #&lt;br /&gt;
 # By Mahram Z.Foadi                                                           #&lt;br /&gt;
 # Oct 22 2005                                                                 # &lt;br /&gt;
 # thank you linuxquestions.org                                                #&lt;br /&gt;
 #                                                                             # &lt;br /&gt;
 # the following lines must be present in your &amp;quot;/etc/acpi/events/&amp;quot; files. Some #&lt;br /&gt;
 # systems already have a file called sample.conf in the mentioned directory   #&lt;br /&gt;
 # rename it to something more meaningful (i.e. acpid.conf) and these lines to #&lt;br /&gt;
 # the end of it  (you don't HAVE to rename it, you can even create a new file #&lt;br /&gt;
 # and call it /etc/acpi/events/lid.conf with the 2 lines in it. If you intend #&lt;br /&gt;
 # to put this file anywhere other than /sbin/lidevent, make sure you make the #&lt;br /&gt;
 # proper changes in the &amp;quot;action&amp;quot; line below. For example if you are going to  #&lt;br /&gt;
 # save this script as /usr/bin/mylid.sh then the action line should be:       #&lt;br /&gt;
 # action=/usr/bin/mylid.sh                                                    #&lt;br /&gt;
 # be sure both files are executable, writable, and owned by root ONLY because #&lt;br /&gt;
 # the acpid daemon is most likely running as root in your system              #&lt;br /&gt;
 #                                                                             #&lt;br /&gt;
 #     ---- insert the two lines below in /etc/acpi/events/acpid.conf ----     #&lt;br /&gt;
 # event=button/lid.*                                                          #&lt;br /&gt;
 # action=/sbin/lidevent                                                       #&lt;br /&gt;
 #-----------------------------------------------------------------------------#&lt;br /&gt;
 &lt;br /&gt;
 # default display on current host&lt;br /&gt;
 DISPLAY=:0.0&lt;br /&gt;
 &lt;br /&gt;
 # find out if DPMS is enabled&lt;br /&gt;
 STATUS=`xset -display $DISPLAY -q | grep -e 'DPMS is'`&lt;br /&gt;
 &lt;br /&gt;
 # enable DPMS if disabled&lt;br /&gt;
 if [ &amp;quot;$STATUS&amp;quot; == &amp;quot;  DPMS is Disabled&amp;quot; ]&lt;br /&gt;
 then&lt;br /&gt;
 	echo &amp;quot;Enabling DPMS ...&amp;quot;&lt;br /&gt;
 	xset -display $DISPLAY +dpms&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
  # find out if monitor is on&lt;br /&gt;
 STATUS=`xset -display $DISPLAY -q | grep 'Monitor'`&lt;br /&gt;
 &lt;br /&gt;
 if [ &amp;quot;$STATUS&amp;quot; == &amp;quot;  Monitor is On&amp;quot; ]&lt;br /&gt;
 then&lt;br /&gt;
 	echo &amp;quot;[`date`] Turning display OFF&amp;quot;&lt;br /&gt;
 	xset -display $DISPLAY dpms force off&lt;br /&gt;
 else&lt;br /&gt;
 	echo &amp;quot;[`date`] Turning display ON&amp;quot;		# shows up in log&lt;br /&gt;
 	xset -display $DISPLAY dpms force on		# turn monitor on&lt;br /&gt;
  	xset -display $DISPLAY s activate		# un-blank monitor&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 #clean up&lt;br /&gt;
 unset STATUS&lt;br /&gt;
 &lt;br /&gt;
 # comment this line out if you're manually running this script from a shell (put a # in front of it)&lt;br /&gt;
 unset DISPLAY&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
 &lt;br /&gt;
An alternative is to call radeontool (if you have a radeon videocard only of course)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Switch external display==&lt;br /&gt;
Again make sure that &lt;br /&gt;
 xhost +local:root  &lt;br /&gt;
&lt;br /&gt;
With the newer versions of X, display switching can be done with xrandr.&lt;br /&gt;
Create the script /etc/acpi/switchdisplay.sh&lt;br /&gt;
 #!/bin/csh&lt;br /&gt;
 /usr/bin/xrandr --output VGA-0 --auto&lt;br /&gt;
&lt;br /&gt;
And /etc/acpi/events/displaybtn&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00001007&lt;br /&gt;
 action=/etc/acpi/switchdisplay.sh&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
*If something doesn't work, your first action should be a {{cmdroot|tail /var/log/acpid}}. It will tell you a lot about what is going on. If it has &amp;quot;Permission denied&amp;quot; errors, check the permissions of your {{path|/etc/acpi/actions}} scripts (especially make sure that the executable bit is set). Also check the permissions for other involved files like i.e. device nodes.&lt;br /&gt;
*For further problems look at the [[Problems with ACPI suspend-to-ram|Problems with ACPI suspend-to-ram page]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:770X]] [[Category:770Z]] [[Category:A20m]] [[Category:A20p]] [[Category:A20m]] [[Category:A20p]] [[Category:A21e]] [[Category:A21m]] [[Category:A21p]] [[Category:A22e]] [[Category:A22m]] [[Category:A22p]] [[Category:G40]] [[Category:G41]] [[Category:R30]] [[Category:R31]] [[Category:R32]] [[Category:R40]] [[Category:R40e]] [[Category:R50]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:T20]] [[Category:T21]] [[Category:T22]] [[Category:T23]] [[Category:T30]] [[Category:T40]] [[Category:T40p]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:X20]] [[Category:X21]] [[Category:X22]] [[Category:X23]] [[Category:X24]] [[Category:X30]] [[Category:X31]] [[Category:X32]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]]  [[Category:Z60t]] [[Category:Z60m]] [[Category:TransNote]]&lt;/div&gt;</summary>
		<author><name>Thjaeger</name></author>
		
	</entry>
</feed>