MacOS 自动切换 APP 当前输入法小工具 1.1.0 更新
https://www.v2ex.com/t/624091
1.1.0 更新内容
增加配置界面
支持配置默认输入法
支持按 app 配置 app 激活 /启动时的默认输入法
下载链接:
https://github.com/leaves615/KeyboardHolder/releases
1.1.0 更新内容
增加配置界面
支持配置默认输入法
支持按 app 配置 app 激活 /启动时的默认输入法
下载链接:
https://github.com/leaves615/KeyboardHolder/releases
“`lua
local function Chinese()
hs.keycodes.currentSourceID(“im.rime.inputmethod.Squirrel.Rime”)
end
local function English()
hs.keycodes.currentSourceID(“com.apple.keylayout.ABC”)
end
— app to expected ime config
local app2Ime = {}
app2Ime[‘iTerm2’] = ‘English’
app2Ime[‘Alfred 3’] = ‘English’
function updateFocusAppInputMethod(appName)
local ime = ‘Chinese’
if app2Ime[appName] then
ime = app2Ime[appName]
end
if ime == ‘English’ then
English()
else
Chinese()
end
end
local focusedApp = {‘iTerm2′,’Google Chrome’,’IntelliJ IDEA’,’IntelliJ IDEA-EAP’,’钉钉’,’Code’,’幕布’}
— 解决固定 APP
hs.window.filter.new(focusedApp)
:subscribe(hs.window.filter.windowFocused,function (win, appName)
–print(‘windowFocused’..appName)
updateFocusAppInputMethod(appName)
end)
— 解决浮动窗口
hs.window.filter.new{‘iTerm2′,’Alfred 3’}:subscribe(hs.window.filter.windowOnScreen,function (win, appName)
–print(‘windowOnScreen’..appName)
updateFocusAppInputMethod(appName)
end):subscribe(hs.window.filter.windowNotOnScreen,function (win, appName)
local frontMostApp = hs.application.frontmostApplication()
updateFocusAppInputMethod(frontMostApp:name())
end)
“`