Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 646230 - x11-wm/awesome: does not handle .desktop file overrides correctly
Summary: x11-wm/awesome: does not handle .desktop file overrides correctly
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Tomoya Tabuchi
URL: https://github.com/awesomeWM/awesome/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-31 18:52 UTC by Viktor Levin
Modified: 2018-03-25 21:09 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Viktor Levin 2018-01-31 18:52:10 UTC
Every time net-im/telegram-desktop-bin is being updated (Telegram version is being increased), in generates file
~/.local/share/applications/telegramdesktop.desktop

This behavior is caused by this code:
https://github.com/telegramdesktop/tdesktop/blob/master/Telegram/SourceFiles/platform/linux/specific_linux.cpp
TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION is undefined by default, and Telegram upstream developers doesn't want to modify this behavior in upstream.

However, each time net-im/telegram-desktop-bin is being emerged, it creates file
/usr/share/applications/telegramdesktop.desktop

So we have two Telegram .desktop files on Linux after update. It causes the following issue: in awesome WM desktop menu or in GNOME/KDE menu we have two Telegram apps instead of one.

Possible solution: net-im/telegram-desktop-bin ebuild should remove /usr/share/applications/telegramdesktop.desktop in src_install() phase.
Comment 1 Henning Schild 2018-01-31 21:28:34 UTC
Good point. I am mainly using plasma and there the .local one seems to win over the one from the package. The KDE menu contains just one entry. The fact that the package brings its own updater and provides such files is a major issue.
I am still hoping we can eventually just compile that without the custom qt.

I just had a quick look at https://specifications.freedesktop.org to figure out what is supposed to happen when having two .desktop-files with the same name. My first wild guess is that there is some kind of preference here and only one entry should end up in the menu (see $PATH). But i could not confirm that without truly reading the spec.

On KDE/Plasma it would probably be ok to not ship a .desktop with the package, but i am not convinced that would work for any GUI-shell.

Will the application always create that file when it is started? But even if, we would not have a .desktop entry for the first launch.
Comment 2 Viktor Levin 2018-01-31 22:41:40 UTC
> Will the application always create that file when it is started?

~/.local/share/applications/telegramdesktop.desktop is being created in two cases:

1. When we launch Telegram for current user for a first time (i.e. this user has no Telegram configs in $HOME at all). In this case, ~/.local/share/applications/telegramdesktop.desktop is created.

2. When we updated Telegram via portage (e.g., from 1.2.1 to 1.2.2) and relaunched it. When Telegram detects that his version is increased, it recreates ~/.local/share/applications/telegramdesktop.desktop.
Comment 3 Viktor Levin 2018-01-31 22:52:20 UTC
Related comment of the main Telegram upstream developer:

https://github.com/telegramdesktop/tdesktop/pull/2181#issuecomment-227749814

TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION is undefined by default in the source code by that developer. Reason:

> The main code branch is used to build a version that is distributed
> through https://desktop.telegram.org/ in a simple compressed way and
> it should work just by download-unpack (like it does right now).
> This is the only version that is currently officially offered by
> Telegram, anyone else can build their own versions with or
> without .desktop file generation and distribute through any package
> manager they prefer.

So in my opinion, there are two ways to fix it:

1. Remove /usr/share/applications/telegramdesktop.desktop in ebuild. This file should not be installed.

2. Maybe provide net-im/telegram-desktop-not-bin with #define TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION defined.

The first way is more simple.
Comment 4 Viktor Levin 2018-01-31 23:01:23 UTC
The same issue on Ubuntu Linux:

https://github.com/telegramdesktop/tdesktop/issues/1127

> I found that there was an extra telegram.desktop placed
> in ~/.local/share/applications. I removed the file and the
> duplicate icon is gone.
Comment 5 Henning Schild 2018-02-01 07:33:34 UTC
(In reply to Viktor Levin from comment #3)
> Related comment of the main Telegram upstream developer:
> 
> https://github.com/telegramdesktop/tdesktop/pull/2181#issuecomment-227749814
> 
> TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION is undefined by default in the
> source code by that developer. Reason:
> 
> > The main code branch is used to build a version that is distributed
> > through https://desktop.telegram.org/ in a simple compressed way and
> > it should work just by download-unpack (like it does right now).
> > This is the only version that is currently officially offered by
> > Telegram, anyone else can build their own versions with or
> > without .desktop file generation and distribute through any package
> > manager they prefer.
> 
> So in my opinion, there are two ways to fix it:
> 
> 1. Remove /usr/share/applications/telegramdesktop.desktop in ebuild. This
> file should not be installed.

In this case there is no .desktop for the initial run, so uses would not find telegram in their launcher menu after installing it. And the .local one would potentially only be visible after that menu cache was rebuild, which telegram might not do.

> 2. Maybe provide net-im/telegram-desktop-not-bin with #define
> TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION defined.

Such a version would be the way to go, but last time i looked into building it from source it pulled in a custom qt and turned out to be very hard. The fact that it updates itself is an even bigger issue that comes with the -bin.
 
> The first way is more simple.
Comment 6 Henning Schild 2018-02-01 07:36:59 UTC
I am tempted to give that bug a wontfix. Are we clear about the .desktop file parsing order and whether two menu-entries are not just a bug in awesome WM. You claimed that KDE is also affected, but i can not confirm that.
Comment 7 Henning Schild 2018-02-01 07:50:20 UTC
I commented on https://github.com/telegramdesktop/tdesktop/pull/2181 and suggested a way to deal with that problem. Not sure if they will react on that. Another way would be to open an issue, but they have so many of them i did not want to create a duplicate.

For now i would suggest to wait and see if an issue would have been the better idea.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-01 08:49:37 UTC
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.2.html#desktop-file-id

If both have the same relative path, only one should be used.
Comment 9 Viktor Levin 2018-02-01 10:47:07 UTC
Guys, Arch Linux wiki says that it is awesome WM menu issue:

https://wiki.archlinux.org/index.php/awesome#Duplicate_menu-entries_generated_by_Xdg-menu

> Xdg-menu will generate duplicate entries if you copy desktop-files from /usr/share/applications to ~/.local/share/applications even though it might be preferable to simply override the originals
Comment 10 Viktor Levin 2018-02-01 10:49:50 UTC
This is not Telegram issue:

https://github.com/awesomeWM/awesome/issues/1816
Comment 11 Viktor Levin 2018-02-01 11:02:15 UTC
I've just re-checked in recent KDE - no bugs found. So it is awesome WM specific bug.
Comment 12 Henning Schild 2018-02-01 19:21:28 UTC
Ok. Viktor i guess we can close this bug now. Maybe the comment in upstream telegram will result in upstream improvements. Please give me the OK to close this one, or do so yourself.
Comment 13 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-02-01 20:29:34 UTC
Nah, let's just update it to point where the bug lies.
Comment 14 Maxim Koltsov (RETIRED) gentoo-dev 2018-03-25 21:09:01 UTC
Well, we'll have to wait for upstream action on this. Hopefully next release will have this fixed.