Skip to content

Instantly share code, notes, and snippets.

@jrongbin
Created June 18, 2017 12:09
Show Gist options
  • Save jrongbin/675262abf08e8b6169ab4c7634dc57dd to your computer and use it in GitHub Desktop.
Save jrongbin/675262abf08e8b6169ab4c7634dc57dd to your computer and use it in GitHub Desktop.
中英文切换
hs.hotkey.bind({"cmd", "alt", "ctrl", "shift"}, "Z", function()
if hs.keycodes.currentSourceID() == "com.apple.keylayout.US" then
hs.eventtap.keyStroke({}, "f19")
end
end)
hs.hotkey.bind({"cmd", "alt", "ctrl", "shift"}, "E", function()
if hs.keycodes.currentSourceID() ~= "com.apple.keylayout.US" then
hs.eventtap.keyStroke({}, "f19")
end
end)
{
"global": {
"check_for_updates_on_startup": false,
"show_in_menu_bar": false,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"rules": [
{
"manipulators": [
{
"description": "轻按左边 shift 切换中文",
"from": {
"key_code": "left_shift",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_shift",
"modifiers": {
"optional": [
"any"
]
}
}
],
"to_if_alone": [
{
"key_code": "z",
"modifiers": [
"left_command",
"left_option",
"left_control",
"left_shift"
]
}
],
"type": "basic"
},
{
"description": "轻按右边 shift 切换英文",
"from": {
"key_code": "right_shift",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_shift",
"modifiers": {
"optional": [
"any"
]
}
}
],
"to_if_alone": [
{
"key_code": "e",
"modifiers": [
"left_command",
"left_option",
"left_control",
"left_shift"
]
}
],
"type": "basic"
},
{
"description": "Change caps_lock to control/esc.",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_control",
"modifiers": {
"optional": [
"any"
]
}
}
],
"to_if_alone": [
{
"key_code": "escape",
"modifiers": {
"optional": [
"any"
]
}
}
],
"type": "basic"
}
]
}
]
},
"devices": [],
"fn_function_keys": {
"f1": "display_brightness_decrement",
"f10": "mute",
"f11": "volume_decrement",
"f12": "volume_increment",
"f2": "display_brightness_increment",
"f3": "mission_control",
"f4": "launchpad",
"f5": "illumination_decrement",
"f6": "illumination_increment",
"f7": "rewind",
"f8": "play_or_pause",
"f9": "fastforward"
},
"name": "Default profile",
"selected": true,
"simple_modifications": {},
"virtual_hid_keyboard": {
"caps_lock_delay_milliseconds": 0,
"keyboard_type": "ansi"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment