V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
nichijou
V2EX  ›  macOS

Mac 上如何优雅地切换三个输入法?

  •  
  •   nichijou · 2019-06-05 20:07:34 +08:00 · 3112 次点击
    这是一个创建于 1784 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我需要切换三个输入法

    https://i.loli.net/2019/06/05/5cf79a690d23162842.png

    然而 command-SPC 切换的方式太慢了

    目前我是用 karabiner 设置 option-1/2/3 分别对应三种输入法,但使用过程依然觉得不流畅(需要去思考按什么),而且在 EL Capitan 下有“切换后图标改变但输入仍是英文”的 bug。

    见到过最优的切换方式应该是 Gboard: 她会在你最近使用的两个输入法间切换,如果切换后你未使用当前输入法进行任何输入,则判定你需要第三种输入法,再按小地球就会切换第三种输入法。

    但该方法似乎只能在输入法内部实现。

    现在我能想到最好的就是通过 hammerspoon 按顺序切换三种输入法,然后在通过 karabiner 把它赋予右 shift。

    function cycleInputMethod()
      if hs.keycodes.currentSourceID() == "com.apple.keylayout.US" then
        hs.keycodes.currentSourceID("com.apple.inputmethod.SCIM.ITABC" )
      elseif hs.keycodes.currentSourceID() == "com.apple.inputmethod.SCIM.ITABC" then
        hs.keycodes.currentSourceID("com.apple.inputmethod.Kotoeri.Japanese")
      elseif hs.keycodes.currentSourceID() == "com.apple.inputmethod.Kotoeri.Japanese" then
        hs.keycodes.currentSourceID("com.apple.keylayout.US")
      end
    end
    

    你有什么好的设计思路吗?

    或者最新版本的 MacOS 有什么变化么?

    第 1 条附言  ·  2019-06-06 16:49:51 +08:00
    用 hammerspoon 和 karabiner 基本实现了类似 Gboard 的功能,基本能保证在但一个输入环境下正常工作,但是如果频繁切换程序,会跑偏。。。

    http://nichijou.city/posts/45I7
    4 条回复    2019-06-06 17:06:37 +08:00
    aec4d
        1
    aec4d  
       2019-06-05 21:17:19 +08:00   ❤️ 1
    我只有两种输入法,切换方案是这样的,如果短按左 shift 就映射为切换输入法,长按就认为是默认 shift
    应该三个输入法也能用
    "complex_modifications": {
    "parameters": {
    "basic.simultaneous_threshold_milliseconds": 50,
    "basic.to_delayed_action_delay_milliseconds": 500,
    "basic.to_if_alone_timeout_milliseconds": 1000,
    "basic.to_if_held_down_threshold_milliseconds": 500,
    "mouse_motion_to_scroll.speed": 100
    },
    "rules": [
    {
    "manipulators": [
    {
    "description": "Change left_shift to command+control+option+shift+p.",
    "from": {
    "key_code": "left_shift",
    "modifiers": {
    "optional": [
    "any"
    ]
    }
    },
    "to": [
    {
    "key_code": "left_shift"
    }
    ],
    "to_if_alone": [
    {
    "key_code": "p",
    "modifiers": [
    "left_command",
    "left_control",
    "left_option",
    "left_shift"
    ]
    }
    ],
    "type": "basic"
    }
    ]
    }
    ]
    }
    nichijou
        2
    nichijou  
    OP
       2019-06-05 21:28:58 +08:00
    @aec4d

    我原来也是这么来的,现在也大概如此。不过不需要这么复杂,还是新的 karabiner 改了?

    老版实现你的只要 __KeyOverlaidModifier__ 即可

    https://gist.github.com/whitemuu/cb784e88881dec04b2f9631c46ffbc10
    ewBuyVmLZMZE
        3
    ewBuyVmLZMZE  
       2019-06-06 13:49:09 +08:00   ❤️ 1


    可以用这个。MLSwitch2
    nichijou
        4
    nichijou  
    OP
       2019-06-06 17:06:37 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1566 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 17:02 · PVG 01:02 · LAX 10:02 · JFK 13:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.