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]).
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.
This worked for me (I am using Ubuntu 12.04 with lightdm):
Maybe also without disper -l and calling disper twice, but I did not check yet