Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.06k stars 583 forks source link

Hammerspoon brings back `com.apple.keylayout.ABC` #3647

Open isudfv opened 4 months ago

isudfv commented 4 months ago

Hi, I'm trying to get rid of com.apple.keylayout.ABC because of this issue, which is already achieved. But when I use hammerspoon to switch input source by hs.keycodes.currentSourceID("org.unknown.keylayout.custom"), hs brings the annoying ABC back. I tried a workaround to execute a shell command issw org.unknown.keylayout.custom (issw), which has the same effect. However that behavior happens only in config and works well in hs console and terminal.

this is my config file, which changes input-source to custom when hit ESC in Android Studio

bEventTap = hs.eventtap.new({ hs.eventtap.event.types.keyDown }, function(event)
  if event:getKeyCode() == 53 then
    local frontApp = hs.application.frontmostApplication()
    if string.match(frontApp:title(), "Android Studio") then
      -- hs.keycodes.currentSourceID("org.unknown.keylayout.custom")
      hs.execute("/Users/isudfv/Desktop/tmp/input-source-switcher/build/issw org.unknown.keylayout.custom")
    end
  end
  return false -- don't delete the event
end)
bEventTap:start()
cmsj commented 2 months ago

hmm, I've not come across this before. I don't believe we're intentionally trying to modify layouts when switching them.