6

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]).

2 Answers 2

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
4
  • 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, 2011 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, 2011 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, 2011 at 20:45
  • this doesn't actually work. :( the file is certainly being written, though.
    – Dang Khoa
    Sep 18, 2011 at 2:36
2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .