From 4321b41021fba4b2242dadecbeaa16169acb4f2c Mon Sep 17 00:00:00 2001 From: schobidotdev Date: Tue, 20 Oct 2026 14:20:44 +0200 Subject: [PATCH] Fix window owner detection for app display names --- internal/findmy/locale.go | 7 ++++--- internal/findmy/locale_test.go | 15 +++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/internal/findmy/locale.go b/internal/findmy/locale.go index 7dd1e88..69ccb6f 100644 --- a/internal/findmy/locale.go +++ b/internal/findmy/locale.go @@ -70,13 +70,14 @@ func detectWindowOwner() string { } // parseDisplayName turns mdls output into a window owner, or "" when Spotlight -// had nothing useful. Without Spotlight metadata for FindMy.app (indexing off or +// had nothing useful. Spotlight may append .app to a localized display name; +// CGWindowList reports the owner without that bundle suffix. Without metadata (indexing off or // the store still rebuilding), mdls falls back to the bundle file name "FindMy", // which no locale uses as its window owner, so the locale table is the better bet. func parseDisplayName(out string) string { - name := strings.TrimSpace(out) + name := strings.TrimSuffix(strings.TrimSpace(out), ".app") switch name { - case "", "(null)", "FindMy", "FindMy.app": + case "", "(null)", "FindMy": return "" } return name diff --git a/internal/findmy/locale_test.go b/internal/findmy/locale_test.go index c90c330..c0e5755 100644 --- a/internal/findmy/locale_test.go +++ b/internal/findmy/locale_test.go @@ -50,12 +50,15 @@ func TestLookupStringsHasItemsTab(t *testing.T) { func TestParseDisplayNameIgnoresBundleFileName(t *testing.T) { cases := map[string]string{ - "Find My\n": "Find My", - "Localiser": "Localiser", - "FindMy\n": "", - "FindMy.app\n": "", - "(null)": "", - "": "", + "Find My\n": "Find My", + "Find My.app\n": "Find My", + "Localiser.app\n": "Localiser", + "Wo ist?.app\n": "Wo ist?", + "Localiser": "Localiser", + "FindMy\n": "", + "FindMy.app\n": "", + "(null)": "", + "": "", } for in, want := range cases { if got := parseDisplayName(in); got != want {