`who` does not show with lightdm logged in users.

Asked by Raphael Gradenwitz

To display some warnings after pressing some acpi-keys on my laptop, i need to detect the display and the actual Xauthority.

With some shell-functions provided by the package 'acpi-support' in the file /usr/share/acpi-support/power-funcs this detection is done with 'who':

getXuser() {
 user=$(who | awk "/:$displaynum)/ { print \$1; exit }")

 if [ x"$user" = x"" ]; then
  user=$(who | awk "/:$displaynum/ { print \$1; exit }")
 fi
 if [ x"$user" != x"" ]; then
         userhome=`getent passwd $user | cut -d: -f6`
         export XAUTHORITY=$userhome/.Xauthority
 else
  export XAUTHORITY=""
 fi
}

getXconsole() {
 console=`fgconsole`;
 displaynum=`ps t tty$console | sed -n -re 's,.*/X .*:([0-9]+).*,\1,p'`
 if [ x"$displaynum" != x"" ]; then
  export DISPLAY=":$displaynum"
  getXuser
 fi
}

Only after I have detected/exported the DISPLAY and XAUTHORITY I can display my zenity windows (with questions and warnings). But unfortunately `who` does not show the logged in user when that user is only logged in at a lightdm session. With the older dm's (gdm, kdm etc) this has always worked.

To reproduce this, you must run `who` from another tty, not from within a gnome-terminal opened inside the x-session because the logged in gnome-terminal provides the information but it disapears after closing the gnome-terminal.

Is this a bug or a feature?

If this is a feature, how does the detection work now or where/with what tool do I have to look?

Regards,
Raphael Gradenwitz

Question information

Language:
English Edit question
Status:
Expired
For:
Light Display Manager Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Raphael Gradenwitz (raphael-gradenwitz) said :
#1

OK, I found a solution for my purpose to warn before i switch between one and two displays:

I simply take the magic cookie from "/var/run/lightdm/root/:$displaynum". The Script invoked by the acpi-event can handle that
... It works:

for x in /tmp/.X11-unix/*; do
    DISPLAY=:${x##*/X}
    XAUTHORITY="/var/run/lightdm/root/$DISPLAY"
    if [ -f "$XAUTHORITY" ]; then
        export DISPLAY
        export XAUTHORITY
        ( zenity --question \
            --title='Switch X-Screen Modus' \
            --text="Wollen Sie den X-Server-Modus auf \"$argument\" umschalten?\n\n\
                         ACHTUNG, X-Server wird dann neu gestartet!!" && switch-x-to $argument ||:
        )
    else
        switch-x-to $argument
    fi
done
exit 0

This way i become my warning before the xserver restarts ..

But still i dont understand why a tool from core-utils is not suported any more the way one would expect..

Regards,
Raphael Gradenwitz

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.