Never mistake an entry edited in place for one we generated

A desktop entry that already lives in ~/.local/share/applications is the
user's own file, patched in place with the original kept aside. It used to
get the same X-MCA-Generated marker as a shadow copy, which made the next
scan skip it, fall back to the system entry, and overwrite the user's file
with a shadow - and then delete it on revert instead of restoring it.

The two cases now carry different markers. Only a shadow is skipped by the
scan and deleted when undoing; an entry patched in place stays in the scan
and is restored from its backup.

Also: resolve the applications screen's labels once instead of per row per
keypress, and drop code nothing calls.
This commit is contained in:
Felitendo committed 2026-08-16 19:56:19 +02:00
1 parent d3c82fdff8
commit 5b1fc84710
10 files changed
+63 -60

No files matched your search

+5 -4
View File
@@ -97,6 +97,9 @@ _mca_desktop_read() {
Hidden=*) DE_HIDDEN="${line#Hidden=}" ;;
Categories=*) DE_CATEGORIES="${line#Categories=}" ;;
MimeType=*) DE_MIME="${line#MimeType=}" ;;
# Only a generated shadow. An entry we edited in place carries
# X-MCA-Patched and is still the application's real entry, so it
# has to stay in the scan.
X-MCA-Generated=*) DE_OURS=1 ;;
esac
done < "$file"
@@ -399,8 +402,8 @@ MCA_PROGS=() # resolved program, or a flatpak app id
MCA_KINDS=() # app | browser | flatpak | steam | unknown | no
# A scan reads every desktop entry on the system, so the menu does it once and
# then redraws from what it found. Anything that changes the answer - applying,
# reverting - invalidates it explicitly.
# then redraws from what it found. Applying rescans on its own, so nothing else
# has to remember to invalidate this.
MCA_SCANNED=0
mca_scan_once() {
@@ -408,8 +411,6 @@ mca_scan_once() {
mca_scan
}
mca_scan_invalidate() { MCA_SCANNED=0; }
mca_scan() {
local dir file id name exec_line prog kind i
local -A seen=()