1
cookiejaysj 2020-05-02 23:10:48 +08:00
挺好用的 支持!
|
2
leaves615 OP @cookiejaysj 谢谢支持。
|
3
nl101531 2020-05-05 17:39:20 +08:00
可以用 Hammerspoon 来实现,脚本可以按照下面方式写,对于 Item 的浮动窗口也能很好支持
```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) ``` |