Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/findmy/locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions internal/findmy/locale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading