Damyan Ivanov wrote:

>  detect_x_display()
>  {
> -    local user
> -    local home
> -    user=$(who | sed -n '/ (:0[\.0]*)$\| :0 /{s/ .*//p;q}')
> -    if [ "$user" = "" ]; then
> +    local _user
> +    local _home
> +    _user=$(who | sed -n '/ (:0[\.0]*)$\| :0 /{s/ .*//p;q}')
> +    if [ "$_user" = "" ]; then
>          # no users seem to be logged on a X display?
>          # try the first logged user without any filters
>          # useful for users starting X via 'startx' after logging
>          # on the console
> -        user=$( who | head -n 1 | cut -d' ' -f1 )
> +        _user=$( who | head -n 1 | cut -d' ' -f1 )
>      fi
> -    home=$(getent passwd $user | cut -d: -f6)
> -    XAUTHORITY=$home/.Xauthority
> +    _home=$(getent passwd $_user | cut -d: -f6)
> +    XAUTHORITY=$_home/.Xauthority
>      if [ -f $XAUTHORITY ]; then
>          export XAUTHORITY
>          export DISPLAY=:0
> +        user=$_user
> +        home=$_home
>      fi
>  }

I hadn't noticed that function before.

lid.sh calls CheckPolicy() from /usr/share/acpi-support/policy-funcs 
which calls getXuser() from /usr/share/acpi-support/policy-funcs, which 
seems to do something similar:

getXuser() {
         user=`finger| grep -m1 ":$displaynum " | awk '{print $1}'`
        if [ x"$user" = x"" ]; then
                user=`finger| grep -m1 ":$displaynum" | awk '{print $1}'`
        fi
        if [ x"$user" = x"" ]; then
                startx=`pgrep -n startx`
                if [ x"$startx" != x"" ]; then
                        user=`ps -o user --no-headers $startx`
                fi
        fi
        if [ x"$user" != x"" ]; then
                userhome=`getent passwd $user | cut -d: -f6`
                export XAUTHORITY=$userhome/.Xauthority
        else
                export XAUTHORITY=""
        fi
        export XUSER=$user
}

Should these be merged?

I'm only familiar with getXuser() because of its bugs; see 
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=497220


Phil.




_______________________________________________
Debian-eeepc-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/debian-eeepc-devel

Reply via email to