fix(hammerspoon/app_toggle): sanitize app names to handle non-printable characters

This commit is contained in:
2025-09-27 05:34:15 +01:00
parent 9fd9b794d5
commit 86c5a45570

View File

@@ -10,7 +10,10 @@ local obj = {}
local function findRunningApp(name, path) local function findRunningApp(name, path)
for _, app in ipairs(hs.application.runningApplications()) do for _, app in ipairs(hs.application.runningApplications()) do
local appName = app:name() -- Get app name, removing any non-printable characters. This specifically
-- fixes WhatsApp, who's name starts with a invisible UTF-8 LRM control
-- character.
local appName = app:name():gsub('[^%g+]', '')
-- app:path() can error for certain pseudo-apps. -- app:path() can error for certain pseudo-apps.
-- Guard with pcall and skip on failure to keep iterating. -- Guard with pcall and skip on failure to keep iterating.