[Debian-eeepc-devel] [eeepc-acpi-scripts PATCH] Allow X detection without an existing console/terminal session
Darren Salt
linux at youmustbejoking.demon.co.uk
Fri Oct 24 12:58:03 UTC 2008
I demand that Damyan Ivanov may or may not have written...
> -=| 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.)
I forgot to mention that I find that the first method only succeeds if a user
is currently logged in via a console or X terminal.
> - _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.
I'm not certain that the first detection method is actually still needed with
this patch; I've not (yet) tested.
> Shouldn't "user=root" actually be "user = $_user"? For example if X was
> started with "startx" from the console...
That doesn't seem to matter, and I don't really see how we could reliably set
it anyway; $_user contains an X process ID, so we'd need to find another
process which shares the same credentials ($DISPLAY and $XAUTHORITY) – but
there's no guarantee that that's owned by whoever actually logged in. (That
said, it's likely to be that user or root.)
--
| Darren Salt | linux or ds at | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + Travel less. Share transport more. PRODUCE LESS CARBON DIOXIDE.
He who knows that enough is enough will always have enough.
More information about the Debian-eeepc-devel
mailing list