-
-
Save fujohnwang/fb43392f40f4bc510675b5cbc7fe9bf0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local obj = {} | |
obj.__index = obj | |
-- Metadata | |
obj.name = "HammerspoonSwitchIME" | |
obj.version = "0.1" | |
obj.author = "Qiangning Hong" | |
obj.license = "MIT" | |
local ENGLISH_ID = "com.apple.keylayout.US" | |
local CHINESE_ID = "im.rime.inputmethod.Squirrel.Hans" | |
local JAPANESE_ID = "com.apple.inputmethod.Kotoeri.RomajiTyping.Japanese" | |
local function switch(id) | |
hs.keycodes.currentSourceID(id) | |
end | |
function obj:bindHotkeys() | |
hs.hotkey.bind({"cmd", "alt"}, "e", function() switch(ENGLISH_ID) end) | |
hs.hotkey.bind({"cmd", "alt"}, "c", function() switch(CHINESE_ID) end) | |
hs.hotkey.bind({"cmd", "alt"}, "j", function() switch(JAPANESE_ID) end) | |
end | |
return obj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment