Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using a Thinkpad W510 and constantly change locations. I'm using disper and auto-disper to change screen profiles (undocked; laptop screen + external screen; two external screens).

I wanted to run auto-disper --change after waking up, so I put the following script in /etc/pm/sleep.d:

#!/bin/bash

case "$1" in
    thaw | resume )
        auto-disper --change &> /home/myHome/autodisper_on_wake.txt
        ;;
esac

Upon wake, I get the following in autodisper_on_wake.txt, indicating that the script did fire:

Assuming disper defaults...
'NoneType' object has no attribute 'endswith'
Unable to fingerprint display configuration
home
school
undocked

But no change happened - despite unplugging my monitor before waking my machine (going from profile 'school' to profile 'undocked'), I'm still in profile 'school'.

Any ideas how to proceed? (FWIW, I changed autorandr to have PROFILE and CONFIG point to my absolute home directory, rather than ~ [I thought maybe wake scripts execute as root, so it would look in ~root for profile data]).

share|improve this question

2 Answers 2

I searched for this auto-disper thing on google and found something by that name at https://github.com/wertarbyte/auto-disper and looked at the source. It appears to be running X11 based commands, but your pm-script is likely not being run with an X11 environment. There's no clean way to do this, but if you make the assumption that your X session will be running on display 0 (which will typically be the case if you are the only one logged in graphically), you might get it working by running the command as your user and setting the DISPLAY environment variable.

#!/bin/bash

case "$1" in
    thaw | resume )
        sudo -u yourusername env DISPLAY=:0 auto-disper --change &> /home/myHome/autodisper_on_wake.txt
    ;;
esac
share|improve this answer
    
yes, that's indeed the correct auto-disper. I'm currently out of town and without need to have this functionality, but I'll test and report ASAP. Is it possible to do the same thing upon boot? –  Dang Khoa Aug 20 '11 at 0:40
1  
@strictlyrude27: not until you have a running X session, so you might want to run it in Startup Applications instead. –  geirha Aug 20 '11 at 9:40
    
that's what i'm doing now. Maybe it's possible to get it to run once I get to the login screen? –  Dang Khoa Aug 20 '11 at 20:45
    
this doesn't actually work. :( the file is certainly being written, though. –  Dang Khoa Sep 18 '11 at 2:36

This worked for me (I am using Ubuntu 12.04 with lightdm):

#!/bin/bash

USERNAME="xxx"
export DISPLAY=":0.0"
export HOME=/home/$USERNAME

if [ "$1" = "suspend" ]
then
    echo "Switching back disper"
    su $USERNAME -c "/usr/bin/python /usr/bin/disper -s" 
fi

if [ "$1" = "resume" ]
then
    echo "Change disper" 
    su $USERNAME -c "DISPLAY=:0.0 disper -l ; sleep 1; DISPLAY=:0.0 disper -S ; sleep 4; DISPLAY=:0.0 disper -S" 
fi

Maybe also without disper -l and calling disper twice, but I did not check yet

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.