Karabiner-Elements でja en vi の3種類の入力ソースを切り替えられるようにする

avatar

Yuji Matsumoto / May 06 2019

(この記事は別のブログサイトに掲載していた記事を移植したものです)

下記の JSON ファイルを適当な名前で .config/karabiner/assets/complex_modifications に置けば、Karabiner-Elements の complex_modifications からルールを import できる。

下記のものは左側の shift と ⌘ を押した時に入力ソースが順番に入れ替わるようにする例。 Mac のショートカットとぶつかってしまっているので後で書き直す。

{
  "title": "Language toggler",
  "rules": [
    {
      "description": "Left_Shift+Left_Command language toggle (en->vi->ja->en...)",
      "manipulators": [
        {
          "conditions": [
            {
              "type": "input_source_if",
              "input_sources": [
                {
                  "language": "en"
                }
              ]
            }
          ],
          "type": "basic",
          "from": {
            "key_code": "left_shift",
            "modifiers": {
              "mandatory": ["left_command"]
            }
          },
          "to": [
            {
              "select_input_source": {
                "language": "vi"
              }
            }
          ]
        },
        {
          "conditions": [
            {
              "type": "input_source_if",
              "input_sources": [
                {
                  "language": "vi"
                }
              ]
            }
          ],
          "type": "basic",
          "from": {
            "key_code": "left_shift",
            "modifiers": {
              "mandatory": ["left_command"]
            }
          },
          "to": [
            {
              "select_input_source": {
                "language": "ja"
              }
            }
          ]
        },
        {
          "conditions": [
            {
              "type": "input_source_if",
              "input_sources": [
                {
                  "language": "ja"
                }
              ]
            }
          ],
          "type": "basic",
          "from": {
            "key_code": "left_shift",
            "modifiers": {
              "mandatory": ["left_command"]
            }
          },
          "to": [
            {
              "select_input_source": {
                "language": "en"
              }
            }
          ]
        }
      ]
    }
  ]
}