From unknown Fri Mar 29 11:30:12 2024 X-Loop: owner@bugs.x2go.org Subject: Bug#774: [X2Go-Dev] Bug#774: please set DESKTOP_SESSION and XDG_CURRENT_DESKTOP like local sessions Reply-To: Ryan Tandy , 774@bugs.x2go.org Resent-From: Ryan Tandy Resent-To: x2go-dev@lists.x2go.org Resent-CC: X2Go Developers X-Loop: owner@bugs.x2go.org Resent-Date: Tue, 17 Mar 2015 19:20:02 +0000 Resent-Message-ID: Resent-Sender: owner@bugs.x2go.org X-X2Go-PR-Message: followup 774 X-X2Go-PR-Package: x2goserver X-X2Go-PR-Keywords: Received: via spool by 774-submit@bugs.x2go.org id=B774.14266199554694 (code B ref 774); Tue, 17 Mar 2015 19:20:02 +0000 Received: (at 774) by bugs.x2go.org; 17 Mar 2015 19:19:15 +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 X-Greylist: delayed 436 seconds by postgrey-1.34 at ymir.das-netzwerkteam.de; Tue, 17 Mar 2015 20:19:11 CET Received: from mail.sd63.bc.ca (mail.sd63.bc.ca [142.31.146.55]) by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id A57245DAA3 for <774@bugs.x2go.org>; Tue, 17 Mar 2015 20:19:11 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.sd63.bc.ca (Postfix) with ESMTP id 27ECC24447DC; Tue, 17 Mar 2015 12:11:53 -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 F6tzfATLcrdl; Tue, 17 Mar 2015 12:11:51 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.sd63.bc.ca (Postfix) with ESMTP id CA7D424441D7; Tue, 17 Mar 2015 12:11:51 -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 eIc1QREg_yXs; Tue, 17 Mar 2015 12:11:51 -0700 (PDT) Received: from bowmore (bowmore.sbo.sd63.bc.ca [10.0.253.103]) by mail.sd63.bc.ca (Postfix) with SMTP id A9551244004B; Tue, 17 Mar 2015 12:11:51 -0700 (PDT) Received: (nullmailer pid 22965 invoked by uid 1000); Tue, 17 Mar 2015 19:11:51 -0000 Date: Tue, 17 Mar 2015 12:11:51 -0700 From: Ryan Tandy To: Mike Gabriel Cc: 774@bugs.x2go.org Message-ID: <20150317191151.GB2066@bowmore> References: <20150129181740.GC2051@bowmore> <20150205113105.Horde.pMAVIXVYS9UljNMdiHh_1w1@mail.das-netzwerkteam.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline In-Reply-To: <20150205113105.Horde.pMAVIXVYS9UljNMdiHh_1w1@mail.das-netzwerkteam.de> User-Agent: Mutt/1.5.21 (2010-09-15) --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Control: tags -1 + patch Hi! Sorry it's taken me so long to get back to you about this. On Thu, Feb 05, 2015 at 11:31:05AM +0000, Mike Gabriel wrote: >On Do 29 Jan 2015 19:17:40 CET, Ryan Tandy wrote: >>I can write a patch that adds all this information to x2goruncommand >>in the existing format. However it occurs to me that it might make >>more sense to parse the files in /usr/share/xsessions and use the >>information directly instead of duplicating it. Please let me know >>which you'd prefer to see. > > >x2goruncommand actually requires a complete rewrite (and has to be >based on freedesktop.org specs). > >Until that happens, let's hard-code this stuff. Please provide your patch. Well, I started doing that, but it ended up being a lot less work (and a lot shorter code) to just take the settings from the session files. :) Please consider the attached patch. It makes x2goruncommand behave more like GDM/LightDM for GNOME-ish sessions. Testing GNOME Flashback on recent Ubuntu requires a couple of patches to Ubuntu packages, which I'm working on getting accepted. Details on Launchpad: https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/1251281/comments/46 https://launchpad.net/~rtandy/+archive/ubuntu/flashback/+packages The gnome-session patch is applicable to Jessie too, but I think it's too late in the freeze to get it accepted now. :( Many thanks for your work on X2Go! -- Ryan Tandy - Programmer/Analyst rtandy@sd63.bc.ca School District 63 (Saanich) 250-652-7385 --a8Wt8u1KmwUX3Y2C Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Launch-gnome-session-using-settings-from-the-session.patch" >From 9d84e88f7a7f4b0d47bfcf933796b2ca7cfd179f Mon Sep 17 00:00:00 2001 From: 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 | 137 ++++++++++++------------------------------ 1 file changed, 39 insertions(+), 98 deletions(-) diff --git a/x2goserver/bin/x2goruncommand b/x2goserver/bin/x2goruncommand index ac7ff7f..c28ada1 100755 --- a/x2goserver/bin/x2goruncommand +++ b/x2goserver/bin/x2goruncommand @@ -83,108 +83,48 @@ elif [ "$sndsys" == "arts" ]; then export ARTS_SERVER="localhost:$4" fi -# 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) -# NOTES on GNOME startup behaviour in different distributions -# =========================================================== - -# 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=2d-gnome -# UNITY -> gnome-session --session=2d-ubuntu -# (GNOME3 based desktop shells) -# Ubuntu 11.10 (oneiric) & 12.04 (precise): -# GNOME -> gnome-session --session=gnome-fallback -# UNITY -> gnome-session --session=ubuntu-2d -# (GNOME3 based desktop shells) -# Ubuntu 12.10 (quantal): -# GNOME -> gnome-session --session=gnome-fallback -# UNITY -> gnome-session --session=ubuntu -# (GNOME3 based desktop shells) -# Ubuntu 13.10 (raring) and later: -# GNOME -> gnome-session --session=gnome-flashback -# UNITY -> gnome-session --session=ubuntu -# (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="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" == "UNITY" ] || [ "$cmd" == "unity" ]; then + x2go_xsession=ubuntu-2d + cmd="gnome-session" +elif [ "$cmd" == "CINNAMON" ] || [ "$cmd" == "cinnamon" ]; then + x2go_xsession=cinnamon2d + cmd="gnome-session" +fi if [ "$cmd" == "GNOME" ] || [ "$cmd" == "gnome-session" ]; then - cmd="/usr/bin/gnome-session" - if [ "$DISTRIB_ID" == "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE >= 13.10" | bc)" == "1" ]; then - export DESKTOP_SESSION="gnome-flashback" - if [ -z "$GTK_MODULES" ] ; then - export GTK_MODULES="unity-gtk-module" - else - export GTK_MODULES="$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 gnome-2d gnome; do + session_desktop=/usr/share/xsessions/"$session".desktop + if [ -f "$session_desktop" ]; then + # Run the command specified in the session file. + cmd="$(sed -n 's/^Exec=//p' "$session_desktop")" + + # Use gnome-session's --disable-acceleration-check option if available. + # The Exec= line might already include it. That's OK. + if $cmd --help | grep -q -- --disable-acceleration-check; then + cmd="$cmd --disable-acceleration-check" + fi + + # Set DESKTOP_SESSION and GDMSESSION to the base name of the session file. + export DESKTOP_SESSION="$session" + export GDMSESSION="$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 :-separated. + export XDG_CURRENT_DESKTOP="$(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")" + fi + + break fi - args=" --session=$DESKTOP_SESSION" - elif [ -e /usr/share/gnome-session/sessions/gnome-flashback.session ]; then - export DESKTOP_SESSION="gnome-flashback" - args=" --session=$DESKTOP_SESSION" - elif [ -e /usr/share/gnome-session/sessions/gnome-fallback.session ]; then - export DESKTOP_SESSION="gnome-fallback" - args=" --session=$DESKTOP_SESSION" - elif [ -e /usr/share/gnome-session/sessions/2d-gnome.session ]; then - export DESKTOP_SESSION="2d-gnome" - args=" --session=$DESKTOP_SESSION" - elif [ "$DISTRIB_ID" == "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE <= 10.10" | bc)" == "1" ]; then - export DESKTOP_SESSION="gnome" - elif cat /etc/debian_version | egrep "^(squeeze|6\.).*" >/dev/null; then - export DESKTOP_SESSION="gnome" - fi - -elif ([ "$cmd" == "UNITY" ] || [ "$cmd" == "unity" ]); then - cmd="/usr/bin/gnome-session" - if [ "$DISTRIB_ID" == "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE >= 12.10" | bc)" == "1" ]; then - export DESKTOP_SESSION="ubuntu" - args=" --session=$DESKTOP_SESSION" - elif [ "$DISTRIB_ID" == "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE == 11.10" | bc)" == "1" -o "$(echo "$DISTRIB_RELEASE == 12.04" | bc)" == "1" ]; then - export DESKTOP_SESSION="ubuntu-2d" - args=" --session=$DESKTOP_SESSION" - elif [ "$DISTRIB_ID" == "Ubuntu" ] && [ "$(echo "$DISTRIB_RELEASE == 11.04" | bc)" == "1" ]; then - export DESKTOP_SESSION="2d-ubuntu" - args=" --session=$DESKTOP_SESSION" - fi - # on earlier Ubuntu versions or with non-Ubuntu Distros the ,,UNITY'' command in X2Go will launch the GNOME2 desktop shell - -elif ([ "$cmd" == "CINNAMON" ] || [ "$cmd" == "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="/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="/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="/usr/bin/gnome-session-cinnamon" - # Fallback to the old behavior. - else - cmd="/usr/bin/gnome-session" - export DESKTOP_SESSION="cinnamon2d" - args=" --session=$DESKTOP_SESSION" - fi + done elif [ "$cmd" == "MATE" ]; then cmd="/usr/bin/mate-session" @@ -293,7 +233,8 @@ if [ "$EXEC" != "" ] && [ -x "$EXEC" ]; then if x2gofeature X2GO_XSESSION &>/dev/null && [ "x$X2GO_SESS_TYPE" = "xD" ]; then STARTUP="$cmd$args" "$X2GO_LIB_PATH/x2gosyslog" "$0" "notice" "launching session with Xsession-x2go mechanism, using STARTUP=\"$STARTUP\"" - XSESSION_EXEC="$cmd" STARTUP="/usr/bin/env LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${STARTUP}" /etc/x2go/Xsession + # LightDM passes the session command as an argument to the session wrapper. Some Ubuntu Xsession.d scripts depend on that. + XSESSION_EXEC="$cmd" STARTUP="/usr/bin/env LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${STARTUP}" /etc/x2go/Xsession "$cmd" else "$X2GO_LIB_PATH/x2gosyslog" "$0" "debug" "executing command \"$cmd$args\"..." -- 1.9.1 --a8Wt8u1KmwUX3Y2C--