sway-launcher-desktop icon indicating copy to clipboard operation
sway-launcher-desktop copied to clipboard

Multiple desktop file entries are shown

Open FunctionalHacker opened this issue 4 years ago • 7 comments

As the title says, the launcher has been showing multiple entries for (I think) all desktop files.

Here is a screenshot

image

FunctionalHacker avatar Jan 09 '20 11:01 FunctionalHacker

Thank your the issue and good to see you again :) If my eyes are not deceiving me, one of them is the history entry (in white) and one is the actual desktop file.

I am aware of this behaviour, but I always felt it's not worth going through the effort of attempting to sort out items that are already appended from history. We can't sort -u since we need to keep the order of items (we do want the history at the bottom).

Existing solutions found on the internet usually deal with duplicates not appearing again, while we need more or less the opposite behaviour.

Maybe this could be adapted so it cleans out the PROVIDERS while using HIST_LINES as a reference... dunno

So I have not yet found a simple solution for this and could not bring myself to dig deep into this, honestly. If you have some ideas on how to do this elegantly or could even provide a PR, then I'd happily look at it, though

Biont avatar Jan 09 '20 14:01 Biont

Thanks for the info. If I find the time, I can try to whip up a PR during the weekend, but no promises :smile:

FunctionalHacker avatar Jan 09 '20 17:01 FunctionalHacker

Okay I have to say that I think my bash/unix skills are not to par to be able to fix this. I hope somebody else will take on the challenge :smile:

FunctionalHacker avatar Jan 16 '20 19:01 FunctionalHacker

should we expect this behavior to disappear? it's still annoying))

MrAkells avatar May 29 '21 03:05 MrAkells

For now, it is a conscious tradeoff because I believe the cost of fixing it is too high.

We'd have some 10k lines to check for duplicates (while keeping sort order) on every invocation, so it might come at a performance penalty in addition to the complexity of the implementation itself.

I would be very happy about suggestions to solve this elegantly though

Biont avatar May 30 '21 05:05 Biont

I've investigated this a bit too, and from what I found, it's because sway-launcher-desktop looks in multiple directories for .desktop files, as well as binaries. The directories I've found it looks in are:

  • $HOME/.local/share/applications/
  • /usr/share/applications/
  • /usr/local/share/applications/ (which doesn't exist on my system)

Maybe we could make it prioritize .desktop files from $HOME/.local/share/applications/ above the others, as this is commonly used when a user want's to modify a .desktop file in one of the other locations (e.g. making Firefox always use Wayland). What I mean, is that the script would find e.g. firefox.desktop in $HOME/.local/share/applications/, and then if it finds another firefox.desktop in one of the other locations it would ignore them. Does this sound like a reasonable approach?

EDIT: It does actually does this. Just tested again after deleting the history file, now it doesn't show duplicates anymore.

samsapti avatar Sep 12 '21 16:09 samsapti

EDIT: It does actually does this. Just tested again after deleting the history file, now it doesn't show duplicates anymore.

Yeah there's a test for this behaviour.

This issue here is really about the fact that the contents of the history file are essentially tacked on after the commands and desktop entries have been produced. It is not trivial to remove the duplicates resulting from this behaviour under the constraints that we have (support arbitrary providers & keep history entries at the bottom). Possible, sure, but probably not in a handful of lines and probably not without a performance hit.

Biont avatar Sep 14 '21 07:09 Biont