Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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

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

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

I searched for this auto-disper thing on google and found something by that name at 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.


case "$1" in
    thaw | resume )
        sudo -u yourusername env DISPLAY=:0 auto-disper --change &> /home/myHome/autodisper_on_wake.txt
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
@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):


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

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

if [ "$1" = "resume" ]
    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" 

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

share|improve this answer

Your Answer


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.