Comment 29 for bug 41994

Revision history for this message
Andrew Oakley (andrew-aoakley) wrote :

Fair enough. The next best situation for Hardy, would be to perfect my workaround script /etc/acpi/local/lid.sh.pre ( https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/41994/comments/21 )

Currently the script detects the XAUTHORITY and DISPLAY environment variables in this manner:

export XAUTHORITY=`ls -1 /home/*/.Xauthority`
export DISPLAY=:0

This is unreliable as I understand things (which may be wrong), since with multiple concurrent logged-on desktop users ("switch users"), there may be more than one .Xauthority file and more than one display.

How, in a shell script or similar, can I detect the currently active console .Xauthority and currently active console display, even if there are multiple concurrent desktop users logged in?