Skip to content

Instantly share code, notes, and snippets.

@netmarkjp
Created June 26, 2019 11:43
Show Gist options
  • Save netmarkjp/234341e4e276eb0b68b980fba4bd9225 to your computer and use it in GitHub Desktop.
Save netmarkjp/234341e4e276eb0b68b980fba4bd9225 to your computer and use it in GitHub Desktop.
xremap: use Muhenkan as modifier
add mod3 = Muhenkan

無変換キーをmodifier扱いすることでAltまで指を曲げなくていいようにする。

Muhenkan+f = Alt+f のようになる。

Karabiner-Elementsのcomplex modificationsで出来た「英数キーを単独押しなら英数、英数押下状態ならコマンド」に寄せる変更。

diff --git a/mrblib/xremap/key_expression.rb b/mrblib/xremap/key_expression.rb
index a322ef0..94e7aeb 100644
--- a/mrblib/xremap/key_expression.rb
+++ b/mrblib/xremap/key_expression.rb
@@ -12,7 +12,7 @@ module Xremap
def split_into_key_and_mods(exp)
modifiers = []
- while exp.match(/\A(?<modifier>(C|Ctrl|M|Alt|Shift|Super|Win))-/)
+ while exp.match(/\A(?<modifier>(C|Ctrl|M|Alt|Shift|Super|Win|Muhenkan))-/)
modifier = Regexp.last_match[:modifier]
modifiers << modifier
exp = exp.sub(/\A#{modifier}-/, '')
@@ -32,6 +32,8 @@ module Xremap
mask |= X11::Mod4Mask
when 'Shift'
mask |= X11::ShiftMask
+ when 'Muhenkan'
+ mask |= X11::Mod3Mask
end
end
mask
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment