[Debian-eeepc-devel] [eeepc-acpi-scripts PATCH] Allow X detection without an existing console/terminal session

Damyan Ivanov dmn at debian.org
Fri Oct 24 12:44:02 UTC 2008


-=| Darren Salt, Fri, Oct 24, 2008 at 12:35:43PM +0100 |=-
> I find that either the first method in detect_x_display() for finding a
> logged-in user succeeds or the second method also fails. This patch replaces
> the second method: rather than extract all logged-in users, look for a
> process which is using a console and has certain environment variables which
> then are used for OSD purposes. (The OSD will also work if a login manager is
> currently in control.)

-        _user=$( who | head -n 1 | cut -d' ' -f1 )
+        #_user=$( who | head -n 1 | cut -d' ' -f1 )
+        _user=$(ps -o pid= -t tty$(fgconsole) | sed -e 's/^\s\+//g' | cut -d' ' -f1)
+        if [ "${_user}" != '' ]; then
+            eval $(sed -e 's/\x00/\n/g' /proc/${_user}/environ | grep '^\(DISPLAY\|XAUTHORITY\)=' | sed -e "s/'/'\\\\''/g; s/=/='/; s/$/'/")
+            DISPLAY="${DISPLAY:-:0}"
+            export XAUTHORITY
+            export DISPLAY
+            user=root
+            home=$(getent passwd $_user | cut -d: -f6)
+        fi
+        return

Looks good and the possibility to have OSD notifications before 
logging in would be very nice.

Shouldn't "user=root" actually be "user = $_user"? For example if 
X was started with "startx" from the console...

-- 
dam            JabberID: dam at jabber.minus273.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/debian-eeepc-devel/attachments/20081024/4ad9dc98/attachment.pgp 


More information about the Debian-eeepc-devel mailing list