Bug Hunting Session
Bug 119881 - get_desktop_environment() doesn't work correctly if $XDG_CURRENT_DESKTOP contains a colon-separated list of strings
Summary: get_desktop_environment() doesn't work correctly if $XDG_CURRENT_DESKTOP cont...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.0.3.2 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:6.2.0 target:6.0.7 target:6.1.2
Keywords:
: 119328 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-09-14 14:49 UTC by Olivier Tilloy
Modified: 2018-09-19 10:15 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Tilloy 2018-09-14 14:49:38 UTC

    
Comment 1 Olivier Tilloy 2018-09-14 14:53:50 UTC
This bug was initially reported in Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libreoffice/+bug/1589215.

According to the FreeDesktop Desktop Entry Specification¹, $XDG_CURRENT_DESKTOP may contain a colon-separated list of strings.

The code in https://github.com/LibreOffice/core/blob/master/vcl/unx/generic/desktopdetect/desktopdetector.cxx#L248 doesn't handle that well, as it tries to match (case-insensitive) on the whole value of the variable.

This results in the desktop not being properly detected in instances where XDG_CURRENT_DESKTOP = "ubuntu:GNOME" (which is the case in Ubuntu 18.04).


¹ https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
Comment 2 Xisco Faulí 2018-09-14 15:03:18 UTC
Hi Olivier,
I think this is the same problem as in bug 119328.
Do you plan to work on this? I provided this patch https://gerrit.libreoffice.org/#/c/60489/ but I'm wondering if we should use something like 'contains' instead...
Comment 3 Xisco Faulí 2018-09-14 15:08:59 UTC
*** Bug 119328 has been marked as a duplicate of this bug. ***
Comment 4 Xisco Faulí 2018-09-14 15:09:35 UTC
Output of 'echo $XDG_CURRENT_DESKTOP' in Ubuntu 18.04 with Unity 7 installed:

Unity:Unity7:ubuntu
Comment 5 Olivier Tilloy 2018-09-14 15:24:44 UTC
Hi Xisco,

Without researching this further, I think what needs to happen is splitting the value of aCurrentDesktop on colons, and iterate until we find a known DE.

In pseudo-code:

  array aCurrentDesktops = aCurrentDesktop.split(":")
  for (de in aCurrentDesktops) {
    if (de.equalsIgnoreAsciiCase("unity")) {
      ret = DESKTOP_UNITY;
      break;
    } else if (de.equalsIgnoreAsciiCase("gnome")) {
      ret = DESKTOP_GNOME;
      break;
    } else if …
  }

I can give it a try next week if you don't beat me to it.
Comment 6 Xisco Faulí 2018-09-14 15:28:20 UTC
yep, I use python too much...
Definitely comment 5 is the way to go. If I have some time during the weekend I will give it a try, otherwise if you don't see any comment from me on Monday, go ahead and fix it.
Comment 7 Xisco Faulí 2018-09-17 15:45:13 UTC
We only use the env variable $XDG_CURRENT_DESKTOP to check unity -> https://gerrit.libreoffice.org/#/c/60592/

Gnome is checked with DESKTOP_SESSION
Comment 8 Commit Notification 2018-09-18 10:51:56 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=79093cce6c3a65f84bbafd172b1e9e6702d3ce75

tdf#119881: Check if Unity/Gnome is separated by colon in XDG_CURRENT_DESKTOP

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Xisco Faulí 2018-09-18 10:57:17 UTC
Cherry-picked to
6.1: https://gerrit.libreoffice.org/#/c/60677/1
6.0: https://gerrit.libreoffice.org/#/c/60678/
Comment 10 Commit Notification 2018-09-18 12:21:03 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0ed572e46a14078c3e96eae063226fcb8823f758&h=libreoffice-6-0

tdf#119881: Check if Unity/Gnome is separated by colon in XDG_CURRENT_DESKTOP

It will be available in 6.0.7.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2018-09-18 12:21:12 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=aedccaa4ce5a3f1cc16da29c775c3b8551974b29&h=libreoffice-6-1

tdf#119881: Check if Unity/Gnome is separated by colon in XDG_CURRENT_DESKTOP

It will be available in 6.1.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.