From rtandy@sd63.bc.ca Fri Mar 20 23:12:38 2015 Received: (at 774) by bugs.x2go.org; 20 Mar 2015 22:12:42 +0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on ymir.das-netzwerkteam.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=ham version=3.3.2 Received: from mail.sd63.bc.ca (mail.sd63.bc.ca [142.31.146.55]) by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id 6CA625DAA4 for <774@bugs.x2go.org>; Fri, 20 Mar 2015 23:12:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.sd63.bc.ca (Postfix) with ESMTP id 9E08B244005C; Fri, 20 Mar 2015 15:12:34 -0700 (PDT) Received: from mail.sd63.bc.ca ([127.0.0.1]) by localhost (mail.sd63.bc.ca [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id kmz6qmdHN7Mh; Fri, 20 Mar 2015 15:12:33 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.sd63.bc.ca (Postfix) with ESMTP id ACB8824447D8; Fri, 20 Mar 2015 15:12:33 -0700 (PDT) X-Virus-Scanned: amavisd-new at sd63.bc.ca Received: from mail.sd63.bc.ca ([127.0.0.1]) by localhost (mail.sd63.bc.ca [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lfDRJUnm5XuA; Fri, 20 Mar 2015 15:12:33 -0700 (PDT) Received: from bowmore (bowmore.sbo.sd63.bc.ca [10.0.253.103]) by mail.sd63.bc.ca (Postfix) with SMTP id 86EF0244005C; Fri, 20 Mar 2015 15:12:33 -0700 (PDT) Received: (nullmailer pid 19062 invoked by uid 1000); Fri, 20 Mar 2015 22:12:33 -0000 Date: Fri, 20 Mar 2015 15:12:33 -0700 From: Ryan Tandy To: Mihai Moldovan Cc: 774@bugs.x2go.org, Mike Gabriel Subject: Re: [X2Go-Dev] Bug#774: Bug#774: please set DESKTOP_SESSION and XDG_CURRENT_DESKTOP like local sessions Message-ID: <20150320221233.GA2119@bowmore> References: <20150129181740.GC2051@bowmore> <20150205113105.Horde.pMAVIXVYS9UljNMdiHh_1w1@mail.das-netzwerkteam.de> <20150317191151.GB2066@bowmore> <550BA6B1.9010809@ionic.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="s2ZSL+KKDSLx8OML" Content-Disposition: inline In-Reply-To: <550BA6B1.9010809@ionic.de> User-Agent: Mutt/1.5.21 (2010-09-15) --s2ZSL+KKDSLx8OML Content-Type: multipart/mixed; boundary="X1bOJ3K7DJ5YkBrT" Content-Disposition: inline --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Mar 20, 2015 at 05:48:49AM +0100, Mihai Moldovan wrote: >This looks interesting, but does it work for non-Ubuntu/Debian systems, >too? Especially old(er) ones like SLE{S,D} 11, EPEL 5 etc.? Tested on CentOS 5 and 6 successfully. CentOS 7 seems to not include the=20 GNOME Flashback components, so I couldn't test there. I wasn't able to get X2Go working at all on OpenSuSE 11. :/ Looks like=20 packages.x2go.org doesn't carry 11 any more? Works on OpenSuSE 12,=20 although the GNOME fallback desktop seems to be affected by a few bugs.=20 I didn't test OpenSuSE 13, but glancing at the repo it looks like they=20 retired the fallback/gnome-panel packages like RHEL7 did. The patch I sent before exports XDG_CURRENT_DESKTOP needlessly in=20 environments that have no value for it (e.g. older GNOME 2). Should be=20 harmless, but even so I'm attaching a corrected patch and interdiff=20 since the previous one. The approach probably extends to non-GNOME desktops too, but I don't=20 know when I would have time to go through and test them all... --=20 Ryan Tandy - Programmer/Analyst rtandy@sd63.bc.ca School District 63 (Saanich) 250-652-7385 --X1bOJ3K7DJ5YkBrT Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Launch-gnome-session-using-settings-from-the-session.patch" Content-Transfer-Encoding: quoted-printable =46rom e184e85cbf28928864fd3d935bced28295e7624f Mon Sep 17 00:00:00 2001 =46rom: Ryan Tandy Date: Tue, 17 Mar 2015 10:39:29 -0700 Subject: [PATCH] Launch gnome-session using settings from the session file. Taking the settings from the session file should be more reliable and future-proof than hard-coding them. This makes X2Go behave more like GDM or LightDM in several cases. Setting DESKTOP_SESSION and XDG_CURRENT_DESKTOP correctly allows Upstart to manage the user session on Ubuntu 13.10 and later. That in turn means GTK_MODULES no longer has to be set manually, since there is an Upstart session job that sets it. Passing the startup command as an argument to the session wrapper is necessary on Ubuntu 15.04 and later. --- x2goserver/bin/x2goruncommand | 140 +++++++++++++-------------------------= ---- 1 file changed, 42 insertions(+), 98 deletions(-) diff --git a/x2goserver/bin/x2goruncommand b/x2goserver/bin/x2goruncommand index ac7ff7f..f35d159 100755 --- a/x2goserver/bin/x2goruncommand +++ b/x2goserver/bin/x2goruncommand @@ -83,108 +83,51 @@ elif [ "$sndsys" =3D=3D "arts" ]; then export ARTS_SERVER=3D"localhost:$4" fi =20 -# detect Ubuntu version via /etc/lsb-release (not supported by Debian) -if [ -e "/etc/lsb-release" ]; then - source /etc/lsb-release -fi - # let x2goruncommand choose what command to use for a given desktop shell = name (GNOME, UNITY, KDE, XFCE4, LXDE, TRINITY, MATE, OPENBOX, ICEWM) =20 -# NOTES on GNOME startup behaviour in different distributions -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -# Debian and every other non-Ubuntu distro launchs GNOME3 (in accelerated = mode) when calling gnome-session - -# Ubuntu launches Unity (in accelerated mode) when calling gnome-session. -# To make the GNOME variants start up properly on Ubuntu, we have to make = the following differentiations - -# Ubuntu 10.10 and earlier (maverick): -# GNOME -> gnome-session -# (would start GNOME2) -# Ubuntu 11.04 (natty): -# GNOME -> gnome-session --session=3D2d-gnome -# UNITY -> gnome-session --session=3D2d-ubuntu -# (GNOME3 based desktop shells) -# Ubuntu 11.10 (oneiric) & 12.04 (precise): -# GNOME -> gnome-session --session=3Dgnome-fallback -# UNITY -> gnome-session --session=3Dubuntu-2d -# (GNOME3 based desktop shells) -# Ubuntu 12.10 (quantal): -# GNOME -> gnome-session --session=3Dgnome-fallback -# UNITY -> gnome-session --session=3Dubuntu -# (GNOME3 based desktop shells) -# Ubuntu 13.10 (raring) and later: -# GNOME -> gnome-session --session=3Dgnome-flashback -# UNITY -> gnome-session --session=3Dubuntu -# (GNOME3 based desktop shells) -# Additionally, $GTK_MODULES must include "unity-gtk-module". -# $GTK_MODULES does not need tha value for any other distro -# or any earlier release of Ubuntu. -# -# The logic for launching GNOME should be generic enough -# to work with every other distro. -# -# Also, it appears that some Linux GNOME2 distros need DESKTOP_SESSION= =3D"gnome" -# while others do not. +# Use the gnome-session logic to launch a Unity 2D or Cinnamon 2D session. +# Fall back to GNOME if the chosen session isn't available. +if [ "$cmd" =3D=3D "UNITY" ] || [ "$cmd" =3D=3D "unity" ]; then + x2go_xsession=3Dubuntu-2d + cmd=3D"gnome-session" +elif [ "$cmd" =3D=3D "CINNAMON" ] || [ "$cmd" =3D=3D "cinnamon" ]; then + x2go_xsession=3Dcinnamon2d + cmd=3D"gnome-session" +fi =20 if [ "$cmd" =3D=3D "GNOME" ] || [ "$cmd" =3D=3D "gnome-session" ]; then - cmd=3D"/usr/bin/gnome-session" - if [ "$DISTRIB_ID" =3D=3D "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE >=3D = 13.10" | bc)" =3D=3D "1" ]; then - export DESKTOP_SESSION=3D"gnome-flashback" - if [ -z "$GTK_MODULES" ] ; then - export GTK_MODULES=3D"unity-gtk-module" - else - export GTK_MODULES=3D"$GTK_MODULES:unity-gtk-module" + # Try to pick an appropriate session file, and take settings from it. + for session in "$x2go_xsession" gnome-flashback-metacity gnome-fallback g= nome-2d gnome; do + session_desktop=3D/usr/share/xsessions/"$session".desktop + if [ -f "$session_desktop" ]; then + # Run the command specified in the session file. + cmd=3D"$(sed -n 's/^Exec=3D//p' "$session_desktop")" + + # Use gnome-session's --disable-acceleration-check option if available. + # The Exec=3D line might already include it. That's OK. + if $cmd --help | grep -q -- --disable-acceleration-check; then + cmd=3D"$cmd --disable-acceleration-check" + fi + + # Set DESKTOP_SESSION and GDMSESSION to the base name of the session fi= le. + export DESKTOP_SESSION=3D"$session" + export GDMSESSION=3D"$session" + + # Try to set a reasonable XDG_CURRENT_DESKTOP. + # gnome-session will overwrite this, but on recent Ubuntu, some helpers= are started by upstart instead of gnome-session. + # DesktopNames field is ;-separated. XDG_CURRENT_DESKTOP should be :-se= parated. + desktopname=3D"$(sed -n '/^DesktopNames=3D/ { s/^DesktopNames=3D//; s/;= /:/g; s/:$//; p; }' "$session_desktop")" + # Before DesktopNames was standardized, a few Ubuntu releases used X-Li= ghtDM-DesktopName. + if [ -z "$desktopname" ]; then + desktopname=3D"$(sed -n 's/^X-LightDM-DesktopName=3D//p' "$session_des= ktop")" + fi + # Only export the variable if set by some session file. + if [ -n "$desktopname" ]; then + export XDG_CURRENT_DESKTOP=3D"$desktopname" + fi + break fi - args=3D" --session=3D$DESKTOP_SESSION" - elif [ -e /usr/share/gnome-session/sessions/gnome-flashback.sessio= n ]; then - export DESKTOP_SESSION=3D"gnome-flashback" - args=3D" --session=3D$DESKTOP_SESSION" - elif [ -e /usr/share/gnome-session/sessions/gnome-fallback.session= ]; then - export DESKTOP_SESSION=3D"gnome-fallback" - args=3D" --session=3D$DESKTOP_SESSION" - elif [ -e /usr/share/gnome-session/sessions/2d-gnome.session ]; th= en - export DESKTOP_SESSION=3D"2d-gnome" - args=3D" --session=3D$DESKTOP_SESSION" - elif [ "$DISTRIB_ID" =3D=3D "Ubuntu" ] && [ "$(echo "$DISTRIB_RELE= ASE <=3D 10.10" | bc)" =3D=3D "1" ]; then - export DESKTOP_SESSION=3D"gnome" - elif cat /etc/debian_version | egrep "^(squeeze|6\.).*" >/dev/null; then - export DESKTOP_SESSION=3D"gnome" - fi - -elif ([ "$cmd" =3D=3D "UNITY" ] || [ "$cmd" =3D=3D "unity" ]); then - cmd=3D"/usr/bin/gnome-session" - if [ "$DISTRIB_ID" =3D=3D "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE >=3D = 12.10" | bc)" =3D=3D "1" ]; then - export DESKTOP_SESSION=3D"ubuntu" - args=3D" --session=3D$DESKTOP_SESSION" - elif [ "$DISTRIB_ID" =3D=3D "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE =3D= =3D 11.10" | bc)" =3D=3D "1" -o "$(echo "$DISTRIB_RELEASE =3D=3D 12.04" | b= c)" =3D=3D "1" ]; then - export DESKTOP_SESSION=3D"ubuntu-2d" - args=3D" --session=3D$DESKTOP_SESSION" - elif [ "$DISTRIB_ID" =3D=3D "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE =3D= =3D 11.04" | bc)" =3D=3D "1" ]; then - export DESKTOP_SESSION=3D"2d-ubuntu" - args=3D" --session=3D$DESKTOP_SESSION" - fi - # on earlier Ubuntu versions or with non-Ubuntu Distros the ,,UNITY'' com= mand in X2Go will launch the GNOME2 desktop shell - -elif ([ "$cmd" =3D=3D "CINNAMON" ] || [ "$cmd" =3D=3D "cinnamon" ]); then - # Cinnamon 2.0 and newer - # The cmd is a script that calls the "cinnamon-session" binary. - if [ -e /usr/bin/cinnamon-session-cinnamon2d ]; then - cmd=3D"/usr/bin/cinnamon-session-cinnamon2d" - # Cinnamon 1.6 & 1.8 - # The cmd is a script that calls the "gnome-session" binary. - elif [ -e /usr/bin/gnome-session-cinnamon2d ]; then - cmd=3D"/usr/bin/gnome-session-cinnamon2d" - # Cinnamon 1.4 - # The cmd is a script that calls the "gnome-session" binary. - elif [ -e /usr/bin/gnome-session-cinnamon ]; then - cmd=3D"/usr/bin/gnome-session-cinnamon" - # Fallback to the old behavior. - else - cmd=3D"/usr/bin/gnome-session" - export DESKTOP_SESSION=3D"cinnamon2d" - args=3D" --session=3D$DESKTOP_SESSION" - fi + done =20 elif [ "$cmd" =3D=3D "MATE" ]; then cmd=3D"/usr/bin/mate-session" @@ -293,7 +236,8 @@ if [ "$EXEC" !=3D "" ] && [ -x "$EXEC" ]; then if x2gofeature X2GO_XSESSION &>/dev/null && [ "x$X2GO_SESS_TYPE" =3D "xD"= ]; then STARTUP=3D"$cmd$args" "$X2GO_LIB_PATH/x2gosyslog" "$0" "notice" "launching session with Xsessi= on-x2go mechanism, using STARTUP=3D\"$STARTUP\"" - XSESSION_EXEC=3D"$cmd" STARTUP=3D"/usr/bin/env LD_LIBRARY_PATH=3D${LD_LI= BRARY_PATH} ${STARTUP}" /etc/x2go/Xsession + # LightDM passes the session command as an argument to the session wrapp= er. Some Ubuntu Xsession.d scripts depend on that. + XSESSION_EXEC=3D"$cmd" STARTUP=3D"/usr/bin/env LD_LIBRARY_PATH=3D${LD_LI= BRARY_PATH} ${STARTUP}" /etc/x2go/Xsession "$cmd" else "$X2GO_LIB_PATH/x2gosyslog" "$0" "debug" "executing command \"$cmd$args\= "..." =20 --=20 1.9.1 --X1bOJ3K7DJ5YkBrT Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Launch-gnome-session-using-settings-from-the-session.patch.diff" diff -u b/x2goserver/bin/x2goruncommand b/x2goserver/bin/x2goruncommand --- b/x2goserver/bin/x2goruncommand +++ b/x2goserver/bin/x2goruncommand @@ -116,12 +116,15 @@ # Try to set a reasonable XDG_CURRENT_DESKTOP. # gnome-session will overwrite this, but on recent Ubuntu, some helpers are started by upstart instead of gnome-session. # DesktopNames field is ;-separated. XDG_CURRENT_DESKTOP should be :-separated. - export XDG_CURRENT_DESKTOP="$(sed -n '/^DesktopNames=/ { s/^DesktopNames=//; s/;/:/g; s/:$//; p; }' "$session_desktop")" + desktopname="$(sed -n '/^DesktopNames=/ { s/^DesktopNames=//; s/;/:/g; s/:$//; p; }' "$session_desktop")" # Before DesktopNames was standardized, a few Ubuntu releases used X-LightDM-DesktopName. - if [ -z "$XDG_CURRENT_DESKTOP" ]; then - export XDG_CURRENT_DESKTOP="$(sed -n 's/^X-LightDM-DesktopName=//p' "$session_desktop")" + if [ -z "$desktopname" ]; then + desktopname="$(sed -n 's/^X-LightDM-DesktopName=//p' "$session_desktop")" + fi + # Only export the variable if set by some session file. + if [ -n "$desktopname" ]; then + export XDG_CURRENT_DESKTOP="$desktopname" fi - break fi done --X1bOJ3K7DJ5YkBrT-- --s2ZSL+KKDSLx8OML Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJVDJtOAAoJECKfzxL11mu2LmEP/ik2e2ybuOfinQVjkkp8CW5d ghAZfnoYBwrgNXCSbhsVt9ud1yM6MHr2g4Lc9+J/jycpn3NMCj16SH3BFIO3BsK1 cV1xph0aVHVwvRvry9mTVd6OLgpSf1pXppdrx5b63CnRhzmYNdV4OeEePx2wWQpR U88jClzrOeEgwOHC9NgjBasxu8ZN9KFxSbWBA9R4XwgNXftM23OJCSGQoChiQmvR Vv4iwctpu0mNkKQPd9Prh6Jq5HLKj5wStfZ0nSPnUJ2b+gNW23518wxbB78s/SsR 6HnOxN13e/Rx05tn34ncn34vR53SSZlsczKjCodKNvncFS1lR6e/dmJHgI1hqvkk 3KglH2siFbHGjicYl/ambMo7ddB61W8v/NOxtGSsxMF9owvGGEPGMF1A6/VPNxG9 h/4yWjRlkFSwZNFUz4sPs5/IFUdHhDPcRPZOqz7y3PEeaxW+5FT21VTMAU3wVAWT tKWemKOP0OAQT3C2UGEkGCVNUGdah2IjtiWSZsE03W0/9sKFEt5Hs7FGmZnQdp9a LFFUZIFbVZMiMNTDnYo72g0UOO4NHg9raxvD8a5SAjLrazs0F6iZOd15kcFtwc1/ WS9zB8FFY/m3Y4FaJYASfnZ6ClRVJ+CP/XKyJVK4ELnV0+R2KT9zahOgdwWwh+y+ WBsvlw31w6Ja2eLfI2e7 =Osuw -----END PGP SIGNATURE----- --s2ZSL+KKDSLx8OML--