retitle 603796 power-funcs makes incorrect assumptions about Xorg
thank you
Actually, there's also the problem that getXuser assumes XAUTHORITY is
placed in the user home; this is false with gdm3.
The attached patch (that includes and supersedes the previous one)
parses the environment of the processes that belong to the user, until
it finds an XAUTHORITY definition.
It's not pretty, but way better than assuming and I can't find an other way.
Cheers,
Luca
--- a/lib/power-funcs 2010-11-17 15:32:48.736097710 +0100
+++ b/lib/power-funcs 2010-11-17 15:34:34.972097708 +0100
@@ -18,8 +18,12 @@
fi
fi
if [ x"$user" != x"" ]; then
- userhome=`getent passwd $user | cut -d: -f6`
- export XAUTHORITY=$userhome/.Xauthority
+ for pid in `ps -U $user -o pid=`; do
+ if grep -z -q XAUTHORITY /proc/$pid/environ; then
+ export `grep -z XAUTHORITY /proc/$pid/environ`
+ break
+ fi
+ done
else
export XAUTHORITY=""
fi
@@ -29,7 +33,7 @@
# getXconsole gets the foreground (console) X user
getXconsole() {
console=`fgconsole`;
- displaynum=`ps t tty$console | sed -n -re 's,.*/X .*:([0-9]+).*,\1,p'`
+ displaynum=`ps t tty$console | sed -n -re 's,.*/X(org)? .*:([0-9]+).*,\2,p'`
if [ x"$displaynum" != x"" ]; then
export DISPLAY=":$displaynum"
getXuser