Drop orphan .desktop entries when their backing command is gone#5964
Open
stefanomainardi wants to merge 1 commit into
Open
Drop orphan .desktop entries when their backing command is gone#5964stefanomainardi wants to merge 1 commit into
stefanomainardi wants to merge 1 commit into
Conversation
`omarchy-refresh-applications` unconditionally copies every file under `applications/*.desktop` into `~/.local/share/applications/`, but never removes anything. So when a user uninstalls a preinstalled package via `omarchy-pkg-remove` (e.g. Typora — `omarchy-base.packages` ships it as a default-install), the omarchy-shipped `.desktop` entry stays behind, the launcher still surfaces it, and clicking it reports `App failure: Command not found: "typora"` (see basecamp#5933). Two changes: 1. `omarchy-refresh-applications` now treats the top-level `applications/*.desktop` set as a reconciliation point — for each source file it inspects the `Exec=` command and either copies the entry (if the command resolves on PATH) or deletes a stale copy in the destination (if it doesn't). Generic by design, so the next preinstalled-then-removed app gets the same self-healing behaviour without another patch. The existing alacritty conditional gets the same symmetric cleanup branch. `applications/hidden/*.desktop` keeps the unconditional copy — those entries are NoDisplay overrides whose presence shouldn't depend on whether the upstream command is currently installed (they exist to suppress, not advertise). 2. `omarchy-pkg-remove` calls `omarchy-refresh-applications` after a successful `pacman -Rns`, so the reconciliation happens immediately on uninstall instead of waiting for the next `omarchy update` / manual refresh. Closes basecamp#5933.
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5933.
omarchy-refresh-applicationsnow reconciles top-levelapplications/*.desktopentries instead of just copying them, andomarchy-pkg-removetriggers a reconcile afterpacman -Rnsso orphan launcher entries disappear immediately on uninstall.Symptom
Reproduction from the issue:
typoraininstall/omarchy-base.packages(preinstalled).omarchy-pkg-removerunspacman -Rns typora.~/.local/share/applications/typora.desktopstays — pacman didn't put it there, omarchy did viaomarchy-refresh-applications.Same shape affects every preinstalled package that omarchy ships a
.desktopoverride for. Today that's just typora in the visible set, but the bug class is general.Fix
1.
bin/omarchy-refresh-applications— reconcile instead of copyBefore:
After:
For each shipped entry, look at the
Exec=command:The same symmetric cleanup is added to the existing
alacrittyconditional, which had the same latent issue.applications/hidden/*.desktopis intentionally untouched — those areNoDisplayoverrides that should ship regardless of whether the upstream command is currently installed (they exist to suppress generic vendor entries, not advertise installed apps).2.
bin/omarchy-pkg-remove— trigger the reconcileWithout this, the fix only kicks in on the next
omarchy updateor manual refresh. With this, removing typora from the Remove menu immediately drops the orphan and walker reflects the change after its own refresh.Why generic rather than typora-specific
Hardcoding typora would be a smaller diff but would leave the same trap for the next preinstalled-then-removed app (any future addition to
applications/*.desktopof an optional preinstall would hit the identical bug). TheExec=introspection is 5 lines and uses primitives already present in the codebase (sed,command -v, the basename + cp/rm pattern). It also matches the spirit of the existingomarchy-cmd-present alacrittyconditional — generalising it rather than adding a new special case for each app.Master backport
Both files are identical between
masteranddev(verified withgit diff origin/master:bin/omarchy-{refresh-applications,pkg-remove} origin/dev:...). Happy to open a parallel PR if you want it backported.Test plan
bash -nclean on both modified scriptsExec=extraction against the currentapplications/*.desktopset (foot, imv, mpv, typora) — sed correctly pulls out the bare command in each case, andcommand -vresolves the ones present on PATH