LoginSignup
24
23

More than 5 years have passed since last update.

OSX上のVirtualBoxを使う時だけKarabinerを無効にする

Posted at

はじめに

Karabiner は OSX の様々なキーバインドを変更できる便利なアプリケーションです

私は、Macbook の英字キーボードで、右/左の Command キーを単体で押すとで「かな」/「英数」を切り替えられるようにしています。こうすると英字キーボードのレイアウトを使いつつも、IMEの切り替えが日本語配列のようになるため非常に有用です。

不便なところ

しかし、設定によってはVirtualBoxのゲストマシンだと設定が競合してしまうことがあります。
たとえば、Karabinerで 左右のコマンドキー(⌘)を「英数/かな」としても使う を有効にしていると、ゲストマシンでコマンドキーを叩いた時にSuperキーとしても機能するのですが、バッククォート( ` ) が入力されてしまいます。

そのため、Virtualboxのウィンドウがアクティブになっている時だけは Karabiner を無効にしたいと思っていたのですが、以下の方法で可能でした。

Karabiner の設定を特定のアプリケーションで無効にする方法

1. 設定ファイルを開く

Karabiner のウィンドウの 'Misc & Uninstall' タブにある Open private.xml ボタンを押すと Finder が開くので private.xml を開きます。

2. private.xml の編集

以下のようにします。

<?xml version="1.0"?>
<root>
  <appdef>
    <appname>VirtualBox</appname>
    <equal>org.virtualbox.app.VirtualBoxVM</equal>
  </appdef>
  <item>
    <name>Disable all settings while using VirtualBox</name>
    <identifier>private.ignore_virtualbox</identifier>
    <only>VirtualBox</only>
    <autogen>__PassThrough__</autogen>
  </item>
</root>

3. 設定を反映

再度 Karabiner の設定画面を開き、 Change Key タブにある Reload XML ボタンを押して設定を反映させます(このときエラーが起きる場合は、XMLが正しく編集できたか確認してください)。

次に、 Search テキストボックスに 「virtualbox」 と入力するとXMLで設定した Disable all settings while using VirtualBox という項目が出てくるはずなので、このチェックボックスを ON にします。

4. できているか確認

これで VirutalBox を使っている間は、Karabiner のすべての設定が無効になっているはずです。

おわりに

Karabiner の private.xml を編集することで、特定のアプリに対して特定の設定を有効にすることができるため、大変便利です。

その他の詳細な設定については、 private.xml Reference Manual を御覧ください。

24
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
23