Compatibility: I run Ubuntu 6.10 Edgy, but this howto is likely to work with any sane ACPI setup.
For the trivial fix, skip to the PROCEDURE section. If you want to understand what's going on, read on.
RATIONALE: If you run Ubuntu on a laptop, and your monitor turns off when you close the lid but doesn't turn back on when you open it, this is for you (skip to the next paragraph). If you have the opposite problem (viz. monitor fails to turn off on closed lid), a slight modification of the script might help you. If you don't have either problem, this guide still might be useful for you. It is likely that gnome-power-manager does the unblanking for you. If there is a problem with it, or if you happen not to be logged in, or if you're at a virtual terminal instead of in X when you open the lid, your monitor might fail to turn on. This howto makes the monitor always turn on when the lid opens, as long as the ACPI daemon is running (which, in general, it should be). No dependence on gnome-power-manager or any other tool.
BACKGROUND: First, we have to understand a little about what happens when the computer detects that the lid has been opened or closed. Basically, the configuration of the ACPI daemon tells it to execute the file /etc/acpi/lid.sh whenever the lid is either opened or closed. This is a bash script that does the following, in order:
- Executes the file /etc/acpi/local/lid.sh.pre if it exists and is executable.
- Checks if a policy manager (that would be gnome-power-manager, or whatever the KDE tool is). If it detects one, it exits and goes no further.
- Checks if the lid was opened or closed.
- Takes the appropriate actions, depending on whether the lid was opened or closed.
- Executes the file /etc/acpi/local/lid.sh.post if it exists and is executable.
PROBLEM: Ok, that sounds good. But there is a problem, at least for me, and apparently for many other Dell laptop owners, and maybe others. The problem is that in addition to this, something, I'm not sure what, always blanks the screen, even if the ACPI daemon is not running! But this something does not unblank the screen. So the screen is always guaranteed to be blanked, even if neither ACPI nor gnome-power-manager nor anything else tells it to blank, but it will not be unblanked unless it is explicitly instructed to. (And obviously, moving the mouse, typing, restarting X, etc. have no effect, or else it wouldn't be a problem.)
SOLUTION: So, the solution? If the screen always insists on blanking when it's closed, then we have to always insist that it unblanks when it opens. As you can see from the list above, the only place we can put something to always have it execute on lid open is in the file /etc/acpi/local/lid.sh.pre. After that, if gnome-power-manager is running, the script will exit, so things after that are not guaranteed to always run. So...
PROCEDURE:
Install vbetool:
Code:
sudo apt-get install vbetool # should already be installed, but just in case
Make the script:
Code:
sudo mkdir -p /etc/acpi/local/
sudo gedit /etc/acpi/local/lid.sh.pre
Put this in /etc/acpi/local/lid.sh.pre:
Code:
#!/bin/sh
grep -q open /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
# lid is open; turn the screen on
vbetool dpms on
fi
If you have the opposite problem, put this in /etc/acpi/local/lid.sh.pre:
Note, I haven't tested this, since I don't have this problem. The only difference is the else clause, though.
Code:
#!/bin/sh
# always turn on screen on open lid, regardless of policy or anything
grep -q open /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
# lid is open; turn the screen on
vbetool dpms on
else
# lid is closed; turn the screen off
vbetool dpms off
fi
And finally, make it executable:
Code:
sudo chmod +x /etc/acpi/local/lid.sh.pre
And that should do it. Whether your're logged in, logged out, on a console, whetever, as long as the ACPI daemon is running, the screen should turn on when the lid opens.
TROUBLESHOOTING: I learned all of this by logging into my laptop from another computer via ssh and watching various logfiles, trying various commands, etc. This was very helpful, as I didn't have to deal with the laptop's own monitor deactivating. If you have ssh set up, using it like this is very useful for sorting out all manner of power-management issues. Running "vbetool dpms [on/off]" over ssh should work, so this also gives you a way to manually unblank the monitor if it gets stuck blank.
Please let me know if you find this helpful, or if you have any questions.
Bookmarks