Merge lp:~mitya57/unity-gtk-module/lp1383382 into lp:unity-gtk-module

Proposed by Dmitry Shachnev
Status: Merged
Approved by: William Hua
Approved revision: no longer in the source branch.
Merged at revision: 333
Proposed branch: lp:~mitya57/unity-gtk-module/lp1383382
Merge into: lp:unity-gtk-module
Diff against target: 22 lines (+7/-5)
1 file modified
data/unity-gtk-module.conf (+7/-5)
To merge this branch: bzr merge lp:~mitya57/unity-gtk-module/lp1383382
Reviewer Review Type Date Requested Status
William Hua (community) Approve
Indicator Applet Developers Pending
Review via email: mp+242916@code.launchpad.net

Commit message

Support multiple desktop names in $XDG_CURRENT_DESKTOP.

Description of the change

Support multiple desktop names in $XDG_CURRENT_DESKTOP.

According to the Desktop Entry Specification,
“If $XDG_CURRENT_DESKTOP is set then it contains a colon-separated list of strings”.

For example, on GNOME Flashback session, $XDG_CURRENT_DESKTOP is now ‘GNOME-Flashback;Unity’,
and we still want to load unity-gtk-module there.

To post a comment you must log in.
Revision history for this message
William Hua (attente) wrote :

The change seems to break under Unity. What's the proper dash syntax is to make it also match when XDG_CURRENT_DESKTOP is just "Unity"?

review: Needs Fixing
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Would not it be better to split string into array?

DESKTOPS=array from $XDG_CURRENT_DESKTOP...
for DESKTOP in $DESKTOPS; do
  if [ "x$DESKTOP" != "xUnity" ] then
    stop
    exit 0
  fi
done

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Oh, what I was trying to use is a bashism. Should be better now.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

What Alberts suggests is also fine, but involves sed:

for DESKTOP in $(echo "$XDG_CURRENT_DESKTOP" | sed 's/;/ /')
do
  if [ "x$DESKTOP" = "xUnity" ] then
    exit 0
  fi
done
stop

William, if you prefer this, then I will use this instead.

Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

XDG_CURRENT_DESKTOP separator is ':' not ';'.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Indeed. Will make that change if William prefers your solution to mine.

Revision history for this message
William Hua (attente) wrote :

Don't we want the opposite effect? The script should exit if all of the tokens are not Unity (i.e. it should not exit if any is Unity)? Also, the sed should end with /g in case there's more than one ':'.

Revision history for this message
William Hua (attente) wrote :

Side note, the case pattern match does seem to work for me.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

exit = "finish the pre-start script, go ahead"
stop = "stop the upstart job, bad desktop"

So, the script gets to the "stop" line only when none of the parts matched Unity.

Revision history for this message
William Hua (attente) wrote :

> for DESKTOP in $(echo "$XDG_CURRENT_DESKTOP" | sed 's/;/ /')
> do
> if [ "x$DESKTOP" = "xUnity" ] then
> exit 0
> fi
> done
> stop

I just tried this, replacing the expression with 's/:/ /g', but it doesn't seem to work with Unity either.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Sorry, I forgot a semicolon before then:

for DESKTOP in $(echo "$XDG_CURRENT_DESKTOP" | sed 's/:/ /')
do
  if [ "x$DESKTOP" = "xUnity" ]; then
    exit 0
  fi
done
stop

Do you prefer this variant?

Revision history for this message
William Hua (attente) wrote :

Ah, thank you! It works now! Can you test it again under GNOME Fallback? I can't seem to get a GNOME Fallback session working. But I tested it under Unity and XFCE.

I don't have a strong preference, either is fine.

review: Approve
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

The Flashback session is currently not working because of <https://<email address hidden>>.

With the proposed upstart patch (and r334 from this branch) applied, everything works fine.

Feel free to merge either r333 or r334 :)

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Err, the correct link should be <http://<email address hidden>>.

Revision history for this message
William Hua (attente) wrote :

Just one minor nitpick, could you please add the trailing 'g' to the sed expression in case there's more than one colon? I can confirm that this works on Unity, GNOME Flashback and XFCE. Thanks Dmitry!

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Done (amended the previous commit).

333. By Dmitry Shachnev

Support multiple desktop names in $XDG_CURRENT_DESKTOP.

According to the Desktop Entry Specification, “If $XDG_CURRENT_DESKTOP
is set then it contains a colon-separated list of strings”.

For example, on GNOME Flashback session, $XDG_CURRENT_DESKTOP is now
‘GNOME-Flashback;Unity’, and we still want to load unity-gtk-module there.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/unity-gtk-module.conf'
2--- data/unity-gtk-module.conf 2014-04-15 12:41:08 +0000
3+++ data/unity-gtk-module.conf 2015-01-15 11:26:26 +0000
4@@ -3,11 +3,13 @@
5 start on starting dbus
6
7 pre-start script
8- if [ "x$XDG_CURRENT_DESKTOP" != "xUnity" ]
9- then
10- stop
11- exit 0
12- fi
13+ for DESKTOP in $(echo "$XDG_CURRENT_DESKTOP" | sed 's/:/ /g')
14+ do
15+ if [ "x$DESKTOP" = "xUnity" ]; then
16+ exit 0
17+ fi
18+ done
19+ stop
20 end script
21
22 script

Subscribers

People subscribed via source and target branches