Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Force Monitor Turn On When You Open the Lid

  1. #1
    Join Date
    Feb 2007
    Beans
    77

    Force Monitor Turn On When You Open the Lid

    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:
    1. Executes the file /etc/acpi/local/lid.sh.pre if it exists and is executable.
    2. 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.
    3. Checks if the lid was opened or closed.
    4. Takes the appropriate actions, depending on whether the lid was opened or closed.
    5. 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.
    Last edited by Darwin Award Winner; May 1st, 2007 at 12:33 AM.

  2. #2
    Join Date
    May 2005
    Location
    Malaysia
    Beans
    185
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Force Monitor Turn On When You Open the Lid

    Dude, you rock! My dang black screen after closing the lid, which forces me to manually power off my computer, has been one of those things that really bugged me about Ubuntu.

    But this fix worked! I only read far enough to know that this applied to me, then skipped right to the code.

    Thanks for this great service you've performed for us Dell Ubuntu users!

  3. #3
    Join Date
    Feb 2007
    Beans
    2

    Re: Force Monitor Turn On When You Open the Lid

    No, this solution doesn't help. It did not work for me. I have a T42 with a Radeon Mobility 9000.

  4. #4
    Join Date
    Nov 2004
    Location
    Guadalajara, Mexico
    Beans
    46
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Force Monitor Turn On When You Open the Lid

    worked on a Dell Inspiron 6000 with the 915GM Intel integrated graphics, i was having this problem since the update to edgy

    thanks man, i really appreciate the explanation, i didn't even knew the existence of vbetool

  5. #5
    Join Date
    Feb 2007
    Beans
    77

    Re: Force Monitor Turn On When You Open the Lid

    Quote Originally Posted by Ivar Nahsesamar View Post
    No, this solution doesn't help. It did not work for me. I have a T42 with a Radeon Mobility 9000.
    I believe there is a program called radeontool that implements the same functionality for ati cards. Try "man radeontool"

  6. #6
    Join Date
    Feb 2007
    Beans
    9

    Re: Force Monitor Turn On When You Open the Lid

    I must be missing something else. On a brand new install of 6.10 I get

    grep: /proc/acpi/button/lid/*/state: No such file or directory
    Also the script fails due to permissions if I run it as a user. If I type
    sudo vbetool dpms on
    before I close the lid and hit enter afterwards, it comes right up with no problems. Is there an alternate location for the lid state somewhere?

  7. #7
    Join Date
    Feb 2007
    Beans
    77

    Re: Force Monitor Turn On When You Open the Lid

    I believe that fails to qualify as a "sane ACPI setup," as mentioned in the requirements. You should make sure that ACPI is working correctly on your laptop. That's beyond the scope of this tutorial, but I'm sure there's a howto on it somewhere. As for the permissions problem, the ACPI daemon will run it with administrator permissions, so no sudo is required in the script.

  8. #8
    Join Date
    May 2006
    Beans
    677
    Distro
    Ubuntu 6.06

    Re: Force Monitor Turn On When You Open the Lid

    My brothers and sisters, the answer has come down from Heaven. This solved my &*!@!#$ problem!

    I've waged a war on this problem for so long, I can't begin to tell you how happy I am. This is exactly what I needed. It turns off the backlight, keeps the computer on to leave all downloads and processes going, AND asks me for my password upon return. Could I ask for more?! No, with the exception of fries and a drink....make that pink lemonade. J'IEP!

    Oh yeah, I have a Dell Inspiron 2200.

  9. #9
    Join Date
    Feb 2007
    Beans
    77

    Re: Force Monitor Turn On When You Open the Lid

    Yes, that's why I chose the lid.pre spproach rather than simply replacing the script.

  10. #10
    Join Date
    Dec 2006
    Location
    Europe
    Beans
    236

    Re: Force Monitor Turn On When You Open the Lid

    What if I just want the monitor turned off after a certain period of inactivity, without closing the lid (which works fine for me)?
    This...
    Code:
    sleep 5 && xset +dpms && xset s off off && xset dpms 0 0 0 && xset dpms force off
    doesn't work. After a few seconds the screen is back on, though black.
    Last edited by IamAcoconut; March 9th, 2007 at 08:31 PM.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •