Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[applications] Fix XDG Desktop Entries shadowing behavior #135

Conversation

nathan818fr
Copy link

On my system, google-chrome is installed from the official debian package.
This creates a Desktop Entry in /usr/share/applications/google-chrome.desktop.
But I don't want to see google-chrome appear in my launchers, so I created a file ~/.local/share/applications/google-chrome.desktop with NoDisplay=true.
This configuration works perfectly with other launchers (and this is the expected behavior, according to the spec.), but not with Albert.

The problem is that Albert treats excluded XDG Desktop Entry (with NoDisplay, NotShowIn, etc.) the same way as invalid entries.
And in this case, the entry is simply skipped and does not override/shadow later entries with the same ID.

So this PR fixes this behavior and makes Albert conform to the XDG Desktop Entry Specification.
When iterating desktop entry files, the old logic was:

  • If a matching ID exists in the apps list -> skip
  • Parse the file
  • If invalid or excluded -> skip
  • Add to the apps list

The new logic is:

  • If a matching ID exists in the known apps list -> skip
  • Parse the file
  • If invalid -> skip
  • Add to the known apps list
  • If excluded -> skip
  • Add to the apps list

try {
return s.at(key);
} catch (const out_of_range&) {
throw KeyDoesNotExist(QString("Section '%1' does not contain a key '%2'.")
Copy link
Author

@nathan818fr nathan818fr Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Here, the KeyDoesNotExist exception was necessarily caught by the encapsulating block and therefore always replaced by a SectionDoesNotExist exception.
This only caused incorrect log messages, but I corrected it anyway since it's related to this PR.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ne plus travailler sur Pactify ?

Copy link
Member

@ManuelSchneid3r ManuelSchneid3r Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pactify? Je ne comprend pas

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that spadeau is a player of my Minecraft server named "Pactify" and that he is commenting here for no good reason. Sorry about that... 🤦

@nathan818fr nathan818fr force-pushed the nathan818fr/fix-xdg-apps-shadowing branch from 1675c86 to 24823b0 Compare October 17, 2024 14:01
@ManuelSchneid3r
Copy link
Member

@nathan818fr i am sorry to say that, because i see you invested a good amount of time, but there is a much simpler solution and it is pretty easy to implement for me, because i just have to revert 9803142. I dont know what i thought while writing this , but obviously it is not spec conformant. the algo is simple (put desktop file ids into a map) and I can easily revert it. thank you for pointing that out.

ManuelSchneid3r added a commit that referenced this pull request Oct 20, 2024
ManuelSchneid3r added a commit that referenced this pull request Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants