Results 1 to 9 of 9

Thread: Set Backlight on Resume Script

  1. #1
    Join Date
    Dec 2012
    Beans
    7

    Set Backlight on Resume Script

    Hello, I have an Acer 5734Z (running Bodhi, technically, but based on Ubuntu.) And there is a problem where the backlight doesn't automatically turn on. In order to turn it on, I must hit the screen brightness keys on my laptop. I can also resume the backlight by typing into terminal:
    Code:
    xbacklight -set 0
    (It is good to note that the backlight values are backwards on my computer, so 0 is brightest and 100 is the most dim.)

    So, I have the following in /etc/pm/sleep.d:
    Code:
    #! /bin/bash
    #This makes the backlight set to 0 when the computer resumes.
    case $1 in
    suspend)
    #echo "Suspeding ..."
    ;;
    resume)
    COMMAND="xbacklight -set 0"
    ;;
    hibernate)
    #echo "Hibernating ..."
    ;;
    thaw)
    COMMAND="xbacklight -set 0"
    ;;
    esac
    exit 0
    When I first added this script, it ran beautifully. However, since I have restarted my computer, it hasn't worked. (I turn my computer off every night.) It doesn't seem that the script is even running. Does anyone know why? Any help would be much appreciated. Thanks!

  2. #2
    Join Date
    Jun 2005
    Location
    Toronto, Canada
    Beans
    Hidden!
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Set Backlight on Resume Script

    Hello and welcome to the forums.

    I'm not sure why the script isn't running, there may be some information in the /var/log/pm-suspend.log file to indicate why its failing.

    As an alternative, you could directly echo brightness values into the backlight interface files. To do so, you would echo a value between 0 and the contents of the file max_brightness to the brightness file. The backlight interface files are located at /sys/class/backlight and there may be more than one, so you'll need to go into each of the directories and test it out.

    For example, if you have an acpi_video0 interface (/sys/class/backlight/acpi_video0) you would have a number of files in that directory. Check the contents of max_brightness and echo a value between 0 and max_brightness to the brightness file:
    Code:
    echo 5 | sudo tee /sys/class/backlight/acpi_video0/brightness
    Once you find the correct interface and correct value to set the brightness, change the line:
    COMMAND="xbacklight -set 0"
    ...to read:
    Code:
    echo X > /sys/class/backlight/INTERFACE/brightness
    ...where X is the value and INTERFACE is the name of the interface (directory).

    As an example:
    Code:
    echo 5 > /sys/class/backlight/acpi_video0/brightness

  3. #3
    Join Date
    Dec 2012
    Beans
    7

    Re: Set Backlight on Resume Script

    Thanks for your help! Unfortunately, that did the exact same thing. When I first made the script, it worked perfectly, however, once I restarted my computer, it stops working.

    EDIT: Now however it came up with an error message (that I could not read) and made it take longer before my brightness up and down keys were able to turn the backlight back on. Also, they didn't work when the error message was up and I wasn't able to get enough light to read it, nor do I know how to take a screenshot in e17.
    EDIT: Okay, set a key to execute a screenshot command successfully, I'll do that if I get the error again.
    EDIT:
    Last edited by AgentOrange96; December 6th, 2012 at 09:17 PM.

  4. #4
    Join Date
    Jun 2005
    Location
    Toronto, Canada
    Beans
    Hidden!
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Set Backlight on Resume Script

    Can you post back the contents of your /var/log/pm-suspend.log file:
    Code:
    pastebinit /var/log/pm-suspend.log
    ...and post back the link that is generated.

    And also a copy of that script in /etc/pm/sleep.d.

  5. #5
    Join Date
    Dec 2012
    Beans
    7

    Re: Set Backlight on Resume Script

    Sure. The log is here. What's interesting is that it says that the execution of the script was successful. If you are looking, the script is called "0000_screenbrightness" and is as follows:
    Code:
    #! /bin/bash
    #This makes the backlight set to 0 when the computer resumes.
    case $1 in
    suspend)
    #echo "Suspeding ..."
    ;;
    resume)
    echo 15 > /sys/class/backlight/acer-wmi/brightness
    echo 736950 > /sys/class/backlight/intel_backlight/brightness
    ;;
    hibernate)
    #echo "Hibernating ..."
    ;;
    thaw)
    echo 15 > /sys/class/backlight/acer-wmi/brightness
    echo 736950 > /sys/class/backlight/intel_backlight/brightness
    ;;
    esac
    exit 0
    For the record, I had it so that it only did acer-wmi, but I then added intel_backlight after that one didn't do it. Again, my original code was in my first post.

  6. #6
    Join Date
    Jun 2005
    Location
    Toronto, Canada
    Beans
    Hidden!
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Set Backlight on Resume Script

    echo 15 > /sys/class/backlight/acer-wmi/brightness
    echo 736950 > /sys/class/backlight/intel_backlight/brightness
    Only one of those should actually work to change the brightness. Can you manually find out which one:
    Code:
    echo 15 | sudo tee /sys/class/backlight/acer-wmi/brightness
    echo 7 | sudo tee /sys/class/backlight/acer-wmi/brightness
    
    echo 736950 | sudo tee /sys/class/backlight/intel_backlight/brightness
    echo 350000 | sudo tee /sys/class/backlight/intel_backlight/brightness
    ...and only keep the one that works in the file.

    According to your logs, this script is executed and there are no errors. Funny that it doesn't work after reboot.

    Can you try inserting a delay in the file to see if maybe you need to wait before changing the brightness? (its a bit of a long shot). Before the "case $1" line, insert:
    Code:
    sleep 5s
    Try playing with 5s (5 seconds) value to see if a delay helps at all.

    EDIT: can you also add, before the "case $1" line the following line:
    Code:
    cat /sys/class/backlight/acer-wmi/brightness
    ...to see if the interface exists as this script runs.

    EDIT2: And one more thought. Is it possible that Enlightenment is running a command/script that affects the brightness when the DE returns? I've never used it so I don't know.
    Last edited by Toz; December 7th, 2012 at 05:14 AM.

  7. #7
    Join Date
    Dec 2012
    Beans
    7

    Re: Set Backlight on Resume Script

    Solved!
    I set the number after "echo" to 0 rather than 736950, (remember, my computer is backwards.) commented out acer-wmi, and then later commented out the delay. (I was wondering why it was taking for ever to suspend, then I remembered.) I restarted my computer and... it still works! Thank you so much. This makes life easier.
    ...now if only I can make my computer resume when I open the lid*...

    My final code is below:
    Code:
    #! /bin/bash
    #This makes the backlight set to 0 when the computer resumes.
    #sleep 15s
    cat /sys/class/backlight/intel_backlight/brightness
    case $1 in
    suspend)
    #echo "Suspeding ..."
    ;;
    resume)
    #echo 15 > /sys/class/backlight/acer-wmi/brightness
    echo 0 > /sys/class/backlight/intel_backlight/brightness
    ;;
    hibernate)
    #echo "Hibernating ..."
    ;;
    thaw)
    #echo 15 > /sys/class/backlight/acer-wmi/brightness
    echo 0 > /sys/class/backlight/intel_backlight/brightness
    ;;
    esac
    exit 0
    I didn't bother to delete everything I don't need, mainly for reference for myself.
    I shall now do your favorite thing and mark this as solved!


    *I don't think this is possible as it doesn't do this in Windows...

  8. #8
    Join Date
    Jun 2005
    Location
    Toronto, Canada
    Beans
    Hidden!
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Set Backlight on Resume Script

    I shall now do your favorite thing and mark this as solved!


    ...now if only I can make my computer resume when I open the lid*...
    Probably best to create a new thread for this issue.

  9. #9
    Join Date
    Dec 2012
    Beans
    7

    Re: Set Backlight on Resume Script

    Quote Originally Posted by Toz View Post



    Probably best to create a new thread for this issue.
    Don't worry, I don't think the BIOS even supports this. Besides, I've had this computer long enough to be in the habit of hitting the spacebar before I have the screen all the way up anyway.
    Thanks again!

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
  •