-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_ime.lua
More file actions
25 lines (24 loc) · 1.28 KB
/
Copy pathauto_ime.lua
File metadata and controls
25 lines (24 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
hs.application.watcher.new(function(appName, eventType, appObject)
if (eventType == hs.application.watcher.activated) then
ABC_APPS = { "Code", "Finder", "GitHub", "Grammarly", "iTerm2", "LeetCode", "Sublime Text", "Termius", "Tower",
"Xcode" }
SHUANGPIN_APPS = {}
if (hs.fnutils.contains(ABC_APPS, appName)) then
hs.console.printStyledtext("Switching to ABC for ", appName)
hs.keycodes.currentSourceID("com.apple.keylayout.ABC")
elseif (hs.fnutils.contains(SHUANGPIN_APPS, appName)) then
hs.console.printStyledtext("Switching to Shuangpin for ", appName)
hs.keycodes.currentSourceID("com.apple.inputmethod.TCIM.Shuangpin")
elseif (appName == "LINE") then
if (hs.window.focusedWindow():title() == "LINE") then
-- Change input method to ShuangPin
hs.console.printStyledtext("Switching to Shuangpin for ", appName)
hs.keycodes.currentSourceID("com.apple.inputmethod.TCIM.Shuangpin")
else
-- Change input method to English
hs.console.printStyledtext("Switching to ABC for ", appName)
hs.keycodes.currentSourceID("com.apple.keylayout.ABC")
end
end
end
end):start()