epoptes team mailing list archive
-
epoptes team
-
Mailing list archive
-
Message #00848
[Merge] lp:~oiteam/epoptes/fix-get-display into lp:epoptes
Laércio de Sousa has proposed merging lp:~oiteam/epoptes/fix-get-display into lp:epoptes.
Requested reviews:
Epoptes Developers (epoptes)
For more details, see:
https://code.launchpad.net/~oiteam/epoptes/fix-get-display/+merge/244765
This patch fixes epoptes-client's script get-display for new contexts, namely:
* systemd-loging has replaced ConsoleKit for seat/session/user management.
* XAUTHORITY file is not found in ~/.Xauthority (KDE and GDM/GNOME store it in different paths).
--
Your team Epoptes Developers is requested to review the proposed merge of lp:~oiteam/epoptes/fix-get-display into lp:epoptes.
=== modified file 'epoptes-client/get-display'
--- epoptes-client/get-display 2012-03-27 14:32:48 +0000
+++ epoptes-client/get-display 2014-12-15 17:13:24 +0000
@@ -38,6 +38,25 @@
fi
}
+find_xauthority() {
+ # Plan A: try GNOME/GDM
+ XAUTHORITY=$(ls /var/run/gdm/auth-for-$USER-*/database)
+ [ -s $XAUTHORITY ] && return
+
+ # Plan B: try KDE
+ UID="$(getent passwd "$USER" | cut -d: -f3)"
+ XAUTHORITY=/tmp/kde-$USER/xauth-$UID-$(echo $DISPLAY | tr ':' '_')
+ [ -s $XAUTHORITY ] && return
+
+ # Plan C: try ~/.Xauthority
+ HOME="$(getent passwd "$USER" | cut -d: -f6)"
+ XAUTHORITY=$HOME/.Xauthority
+ [ -s $XAUTHORITY ] && return
+
+ #Plan D: give up!
+ unset XAUTHORITY
+}
+
# Plan A: check if the variables are already set
exit_if_found
@@ -49,30 +68,55 @@
exit_if_found
done
-# Plan C: try ck-list-sessions
-while read var equals value; do
- case "$var" in
- Session*)
- unset USER DISPLAY XAUTHORITY
- ;;
- unix-user)
- value=${value%\'}
- USER=${value#\'}
- ;;
- x11-display)
- value=${value%\'}
- DISPLAY=${value#\'}
- if [ -n "$DISPLAY" ]; then
- XAUTHORITY="$(getent passwd "$USER" | cut -d: -f6)/.Xauthority"
- exit_if_found
- fi
- ;;
- esac
-done <<EOF
+# Plan C: try loginctl
+if [ -x /usr/bin/loginctl ]; then
+ for session in $(loginctl --no-legend | awk '{ print $1 }'); do
+ while read line; do
+ eval $line
+ case "$line" in
+ Name*)
+ USER=$Name
+ ;;
+ Display*)
+ DISPLAY=$Display
+ if [ -n "$DISPLAY" ]; then
+ find_xauthority
+ exit_if_found
+ fi
+ ;;
+ esac
+ done << EOF
+$(loginctl show-session $session)
+EOF
+ done
+fi
+
+# Plan D: try ck-list-sessions
+if [ -x /usr/bin/ck-list-sessions ]; then
+ while read var equals value; do
+ case "$var" in
+ Session*)
+ unset USER DISPLAY XAUTHORITY
+ ;;
+ unix-user)
+ value=${value%\'}
+ USER=${value#\'}
+ ;;
+ x11-display)
+ value=${value%\'}
+ DISPLAY=${value#\'}
+ if [ -n "$DISPLAY" ]; then
+ find_xauthority
+ exit_if_found
+ fi
+ ;;
+ esac
+ done <<EOF
$(ck-list-sessions)
EOF
+fi
-# Plan D: give up!
+# Plan E: give up!
echo "Could not detect or access the active display" >&2
echo "DISPLAY=
XAUTHORITY="