calling disper from script

Bug #330258 reported by cosine
36
This bug affects 6 people
Affects Status Importance Assigned to Milestone
disper
Confirmed
Undecided
wvengen

Bug Description

Hi

I try to call "disper -i" from a udev script, but can't get it to work.
Not even with the DISPLAY env. set.

THe log reports
" import not yet implemented"

disper --version
disper 0.2.1

Revision history for this message
wvengen (wvengen) wrote :

Thanks for your bug report.

I assume you have an nVidia card. This currently happens when an error occurs in loading the nVidia backend and disper falls back to the XRandR backend which hasn't import implemented. DISPLAY should be ok, or disper should complain about not finding a backend.

Could you include the output from disper as run from the udev script with verbose output (add -v to commandline)?
To see better what's happening, please save the attached file somewhere and run it from the udev script (with DISPLAY set correctly).

Changed in disper:
assignee: nobody → wvengen
status: New → Incomplete
Revision history for this message
cosine (mvanross) wrote :

I fix it by setting $HOME in the script, as otherwise it cannot find .Xautorithy

Now I have the files
/etc/udev/rules.d/11-docking.rules

ENV{EVENT}=="undock", KERNEL=="dock.0", SUBSYSTEM=="platform", RUN+="/home/vrossum/scripts/disper.laptop_only"
ENV{EVENT}=="dock", KERNEL=="dock.0", SUBSYSTEM=="platform", RUN+="/home/vrossum/scripts/disper.dock"

And

/home/vrossum/scripts/disper.dock:

#!/bin/bash
export DISPLAY=:0
export HOME=/home/vrossum
/usr/bin/disper -i < /home/vrossum/disper.dell

Of course you will have to edit according to your local config.

Changed in disper:
status: Incomplete → Fix Released
Revision history for this message
wvengen (wvengen) wrote :

Interesting use. In general, disper run from system scripts should take the Xauthority from the current X user. It may be even cleaner to take the credentials and environment from the currently logged in user. When multiple X servers are active the situation is still open.
Ideally disper should be able to figure this out all by itself when run as root without a DISPLAY.

Setting status to Invalid to indicate this is not a disper bug or feature request. Please re-open if you consider this an important feature request.

Changed in disper:
status: Fix Released → Invalid
Revision history for this message
cosine (mvanross) wrote :

It works for me now. Perhaps a possibly more general solution can be found using the scripts at

http://www.thinkwiki.org/wiki/Script_for_Dynamic_Display_Management_with_fglrx

and

http://www.thinkwiki.org/wiki/Sample_Fn-F7_script

Revision history for this message
padrino (padrino121) wrote :

I just tried something similar with disper 0.2.3 and Ubuntu 9.10 and it took me a couple of hours to figure out why it was defaulting to the XRandr backend even through it had a good DISPLAY and I was pointing it to my home directory. It turns out disper falls back to ~/.Xauthority when trying to get the proper file however for whatever reason in Ubuntu 9.10 the Xauthority is in /var/run/gdm/auth-for-username-sesstionstring/database. I manually point the env variable in my script so disper runs correctly but the built in detection in xauth.py can't handle this type of Xauthority, I'm not sure what the cleanest way is to auto detect it there as a backup.

Revision history for this message
wvengen (wvengen) wrote :

Thanks for your comment, padrino. Looking at existing X scripts run from acpi events, I see that they too look just for ~/.Xauthority (see /usr/share/acpi-support/power-funcs on Ubuntu 9.10).

Revision history for this message
cosine (mvanross) wrote :

For some reason I have again problems with this.

The nvtest script gives as error:

Traceback (most recent call last):
  File "/tmp/nvtest.py", line 9, in <module>
    backend = NVidiaSwitcher()
  File "/usr/share/disper/src/switcher/swnvidia.py", line 32, in __init__
    self.nv = nvidia.NVidiaControl()
  File "/usr/share/disper/src/nvidia/nvctrl.py", line 570, in __init__
    self.init_NV_CONTROL()
  File "/usr/share/disper/src/nvidia/nvctrl.py", line 578, in init_NV_CONTROL
    self.xsock, self.xconn = minx.XConnect()
  File "/usr/share/disper/src/nvidia/minx.py", line 403, in XConnect
    auth_name, auth_data = xnet.get_X_auth( xsock, name, host, displayno )
TypeError: 'NoneType' object is not iterable
disper.dell_only called

Revision history for this message
Lorant Nemeth (loci) wrote :

I'm trying to set up the same docking/undocking functionality with disper as xrandr doesn't give valuable output (using T61P with nvidia Quadro FX 570M):

loci@kolibri:~$ xrandr -d :0.0 --verbose|grep conne
xrandr: Failed to get size of gamma for output default
default connected 2560x1024+0+0 (0x4da) normal (normal) 0mm x 0mm

disper however works like a charm from within the X session, but not from the script. While playing with the script I found an interesting scenario:

- open gnome-terminal
- disper -l works with normal user
- sudo su -
- disperl -l works fine
- root@kolibri:~# echo $DISPLAY
:0.0
- unset DISPLAY
- disperl -l says No suitable backend found
- DISPLAY=:0.0
- disperl -l says No suitable backend found

So disper works after sudo su -, but if I unset and set DISPLAY to the same value (:0.0) it doesn't. XAUTHORITY=/var/run/gdm/auth-for-username-sesstionstring/database in both cases, HOME=/root.

Was anybody able to set up a script which can handle the dock event and change settings based on connected device types/numbers?

Revision history for this message
Saša Tomić (tomic80) wrote :

I finally found a solution that works for me. My computer finally suspends and resumes perfectly! :)

To solve this disper problem, I had to get the running X processes and extract and use their authorization token.

Please check the attached script for details.

The script also contains a fix for one other bug with Nvidia drivers on Ubuntu 10.10, so you can ignore this part (or use it if you like)

You can save the script (as I do) to
/etc/pm/sleep.d/99nv-suspend-fix

and it will be executed every time the computer goes to sleep and resumes.

Revision history for this message
Cas (calumlind) wrote :

I encountered this same bug but found an alternative solution that I thought I would share. The script is export_x_info, detailed in the link below, that exports the dbus session address on startup to a file for use by my scripts

http://askubuntu.com/questions/42741/how-to-automatically-switch-monitors-with-my-laptop-dock/48627#48627

It was found in a thread on the Ubuntu forums: http://ubuntuforums.org/showthread.php?t=1076486

wvengen (wvengen)
Changed in disper:
status: Invalid → Confirmed
Revision history for this message
Brian R. Hellman (brian-linbit) wrote :

Seems to be fixed in 0.3.0-1 but broke again in 0.3.1, downgrading back to 0.3.0-1 allows my scripts to work again. KUbuntu 12.04

Revision history for this message
wvengen (wvengen) wrote :

Hi brian, thanks for your notice! This is an important regression. Would you be able to provide more info on that? I'd be interested in the output of the disper invocation with the -v flag, for both 0.3.0-1 and 0.3.1.
If you're using an nVidia card, what driver version do you have?
It would be great if you could open a new bug with this, because this regression may be a separate issue.

Revision history for this message
Brian (x-brian) wrote :

(Different Brian)

$ disper --version
disper 0.3.1

$ disper -p -v
Enabled plugins:
NVidia kernel driver version: 304.88
backend: XRandR
export not yet implemented

$ cat cloned-display.conf | disper -i -v
Enabled plugins:
NVidia kernel driver version: 304.88
backend: XRandR
import not yet implemented

--After force downgrade in Synaptic:

$ disper --version
disper 0.3.0

$ disper -p -v
Enabled plugins:
could not get scaling for screen CRT-0, reverting to "default"
could not get scaling for screen DFP-0, reverting to "default"
could not get scaling for screen DFP-1, reverting to "default"
could not get scaling for screen DFP-2, reverting to "default"
could not get scaling for screen DFP-3, reverting to "default"
could not get scaling for screen DFP-4, reverting to "default"
backend: nvidia
associated displays: CRT-0, DFP-0, DFP-1, DFP-2, DFP-3, DFP-4
metamode: DFP-3: nvidia-auto-select @1440x900 +0+0, DFP-0: nvidia-auto-select @1440x900 +0+0
scaling: default, default, default, default, default, default
xinerama info order: DFP-3, DFP-0

$ cat cloned-display.conf | disper -i -v
Enabled plugins:
adding metamode: DFP-0: nvidia-auto-select @1440x900 +0+0, DFP-3: nvidia-auto-select @1440x900 +0+0
setting xinerama info order: DFP-3, DFP-0
associating displays: DFP-0, DFP-3
setting scaling of display DFP-0 to stretched
setting scaling of display DFP-3 to stretched

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.