From 0e9e326d58d8a66043cc2bb6a6f3b62d0ac5e1e0 Mon Sep 17 00:00:00 2001 From: NagayamaRyoga Date: Thu, 3 Oct 2024 22:36:25 +0900 Subject: [PATCH] Update karabiner config --- config/karabiner/karabiner.json | 3603 ++++++++++++++++++++++++++++++- config/karabiner/karabiner.ts | 419 ++++ config/karabiner/utils.ts | 142 ++ 3 files changed, 4067 insertions(+), 97 deletions(-) create mode 100755 config/karabiner/karabiner.ts create mode 100644 config/karabiner/utils.ts diff --git a/config/karabiner/karabiner.json b/config/karabiner/karabiner.json index 0f3861e..b994bc9 100644 --- a/config/karabiner/karabiner.json +++ b/config/karabiner/karabiner.json @@ -1,8 +1,10 @@ { "global": { + "ask_for_confirmation_before_quitting": true, "check_for_updates_on_startup": true, "show_in_menu_bar": true, - "show_profile_name_in_menu_bar": false + "show_profile_name_in_menu_bar": false, + "unsafe_ui": false }, "profiles": [ { @@ -10,15 +12,22 @@ "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, + "basic.to_if_alone_timeout_milliseconds": 250, + "basic.to_if_held_down_threshold_milliseconds": 250, "mouse_motion_to_scroll.speed": 100 }, "rules": [ { - "description": "Change Command+Backward-Delete and Option+Backward-Delete", + "description": "Exchange Command+Backspace/Delete and Option+Backspace/Delete", "manipulators": [ { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + } + ], "from": { "key_code": "delete_or_backspace", "modifiers": { @@ -26,7 +35,7 @@ "command" ], "optional": [ - "any" + "shift" ] } }, @@ -39,13 +48,15 @@ } ], "type": "basic" - } - ] - }, - { - "description": "Change Option+Backward-Delete to Command+Backward-Delete", - "manipulators": [ + }, { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + } + ], "from": { "key_code": "delete_or_backspace", "modifiers": { @@ -53,7 +64,7 @@ "option" ], "optional": [ - "any" + "shift" ] } }, @@ -66,46 +77,134 @@ } ], "type": "basic" - } - ] - }, - { - "description": "Change Command+Forward-Delete and Option+Forward-Delete", - "manipulators": [ + }, { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + } + ], "from": { - "key_code": "forward_delete", + "key_code": "delete_forward", "modifiers": { "mandatory": [ "command" ], "optional": [ - "any" + "shift" ] } }, "to": [ { - "key_code": "forward_delete", + "key_code": "delete_forward", "modifiers": [ "option" ] } ], "type": "basic" - } - ] - }, - { - "description": "Change Option+Forward-Delete to Command+Forward-Delete", - "manipulators": [ + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + } + ], + "from": { + "key_code": "delete_forward", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "delete_forward", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "delete_or_backspace", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "delete_forward", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], "from": { - "key_code": "forward_delete", + "key_code": "delete_or_backspace", "modifiers": { "mandatory": [ "option" ], + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "delete_forward", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "delete_or_backspace", + "modifiers": { "optional": [ "any" ] @@ -113,13 +212,91 @@ }, "to": [ { - "key_code": "forward_delete", + "key_code": "delete_forward" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "delete_or_backspace", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "delete_forward", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "delete_or_backspace", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "delete_forward", "modifiers": [ "command" ] } ], "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "delete_or_backspace", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "delete_forward" + } + ], + "type": "basic" } ] }, @@ -128,7 +305,7 @@ "manipulators": [ { "from": { - "key_code": "right_arrow", + "key_code": "left_arrow", "modifiers": { "mandatory": [ "command", @@ -141,7 +318,7 @@ }, "to": [ { - "key_code": "right_arrow", + "key_code": "left_arrow", "modifiers": [ "command", "option" @@ -155,8 +332,7 @@ "key_code": "left_arrow", "modifiers": { "mandatory": [ - "command", - "option" + "command" ], "optional": [ "any" @@ -167,7 +343,6 @@ { "key_code": "left_arrow", "modifiers": [ - "command", "option" ] } @@ -176,10 +351,9 @@ }, { "from": { - "key_code": "up_arrow", + "key_code": "left_arrow", "modifiers": { "mandatory": [ - "command", "option" ], "optional": [ @@ -189,10 +363,9 @@ }, "to": [ { - "key_code": "up_arrow", + "key_code": "left_arrow", "modifiers": [ - "command", - "option" + "command" ] } ], @@ -224,7 +397,7 @@ }, { "from": { - "key_code": "right_arrow", + "key_code": "down_arrow", "modifiers": { "mandatory": [ "command" @@ -236,7 +409,7 @@ }, "to": [ { - "key_code": "right_arrow", + "key_code": "down_arrow", "modifiers": [ "option" ] @@ -246,10 +419,10 @@ }, { "from": { - "key_code": "left_arrow", + "key_code": "down_arrow", "modifiers": { "mandatory": [ - "command" + "option" ], "optional": [ "any" @@ -258,9 +431,9 @@ }, "to": [ { - "key_code": "left_arrow", + "key_code": "down_arrow", "modifiers": [ - "option" + "command" ] } ], @@ -271,7 +444,8 @@ "key_code": "up_arrow", "modifiers": { "mandatory": [ - "command" + "command", + "option" ], "optional": [ "any" @@ -282,6 +456,7 @@ { "key_code": "up_arrow", "modifiers": [ + "command", "option" ] } @@ -290,7 +465,7 @@ }, { "from": { - "key_code": "down_arrow", + "key_code": "up_arrow", "modifiers": { "mandatory": [ "command" @@ -302,7 +477,7 @@ }, "to": [ { - "key_code": "down_arrow", + "key_code": "up_arrow", "modifiers": [ "option" ] @@ -312,7 +487,7 @@ }, { "from": { - "key_code": "right_arrow", + "key_code": "up_arrow", "modifiers": { "mandatory": [ "option" @@ -324,7 +499,7 @@ }, "to": [ { - "key_code": "right_arrow", + "key_code": "up_arrow", "modifiers": [ "command" ] @@ -334,9 +509,10 @@ }, { "from": { - "key_code": "left_arrow", + "key_code": "right_arrow", "modifiers": { "mandatory": [ + "command", "option" ], "optional": [ @@ -346,9 +522,10 @@ }, "to": [ { - "key_code": "left_arrow", + "key_code": "right_arrow", "modifiers": [ - "command" + "command", + "option" ] } ], @@ -356,10 +533,10 @@ }, { "from": { - "key_code": "up_arrow", + "key_code": "right_arrow", "modifiers": { "mandatory": [ - "option" + "command" ], "optional": [ "any" @@ -368,9 +545,9 @@ }, "to": [ { - "key_code": "up_arrow", + "key_code": "right_arrow", "modifiers": [ - "command" + "option" ] } ], @@ -378,7 +555,7 @@ }, { "from": { - "key_code": "down_arrow", + "key_code": "right_arrow", "modifiers": { "mandatory": [ "option" @@ -390,7 +567,7 @@ }, "to": [ { - "key_code": "down_arrow", + "key_code": "right_arrow", "modifiers": [ "command" ] @@ -409,13 +586,18 @@ "modifiers": { "mandatory": [ "shift" - ], - "optional": [ - "caps_lock" ] } }, "to": [ + { + "key_code": "left_command", + "modifiers": [ + "shift" + ] + } + ], + "to_if_alone": [ { "key_code": "hyphen" }, @@ -434,13 +616,18 @@ "modifiers": { "mandatory": [ "command" - ], - "optional": [ - "caps_lock" ] } }, "to": [ + { + "key_code": "left_command", + "modifiers": [ + "shift" + ] + } + ], + "to_if_alone": [ { "key_code": "equal_sign" }, @@ -454,22 +641,3151 @@ "type": "basic" }, { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], "from": { "key_code": "caps_lock" }, "to": [ { - "key_code": "hyphen", + "key_code": "left_command", "modifiers": [ "shift" ] } ], + "to_if_alone": [ + { + "key_code": "hyphen" + } + ], "type": "basic" - } - ] - } - ] + }, + { + "from": { + "key_code": "caps_lock", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_command", + "modifiers": [ + "shift" + ] + } + ], + "to_if_alone": [ + { + "key_code": "hyphen", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + } + ] + }, + { + "description": "Lower Layer", + "manipulators": [ + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "1" + }, + "to": [ + { + "key_code": "1", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "2" + }, + "to": [ + { + "key_code": "2", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "3" + }, + "to": [ + { + "key_code": "3", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "4" + }, + "to": [ + { + "key_code": "4", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "5" + }, + "to": [ + { + "key_code": "5", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "6" + }, + "to": [ + { + "key_code": "6", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "7" + }, + "to": [ + { + "key_code": "7", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "8" + }, + "to": [ + { + "key_code": "8", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "9" + }, + "to": [ + { + "key_code": "9", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "0" + }, + "to": [ + { + "key_code": "0", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "hyphen" + }, + "to": [ + { + "key_code": "hyphen", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "equal_sign" + }, + "to": [ + { + "key_code": "equal_sign", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "q" + }, + "to": [ + { + "key_code": "1", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "w" + }, + "to": [ + { + "key_code": "2", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "e" + }, + "to": [ + { + "key_code": "3", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "r" + }, + "to": [ + { + "key_code": "4", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "t" + }, + "to": [ + { + "key_code": "5", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "a" + }, + "to": [ + { + "key_code": "6", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "s" + }, + "to": [ + { + "key_code": "7", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "d" + }, + "to": [ + { + "key_code": "8", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "f" + }, + "to": [ + { + "key_code": "equal_sign" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "g" + }, + "to": [ + { + "key_code": "equal_sign", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "j", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "j", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "j", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "j", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "k", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "k", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "k", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "k", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "i", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "i", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "i", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "i", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "l", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "l", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "l", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "l", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "u", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "home" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "o", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "end" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "p", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "page_up" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "semicolon", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "page_down" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "z" + }, + "to": [ + { + "key_code": "9", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "x" + }, + "to": [ + { + "key_code": "0", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "c" + }, + "to": [ + { + "key_code": "slash" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "v" + }, + "to": [ + { + "key_code": "slash", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "open_bracket" + }, + "to": [ + { + "key_code": "open_bracket", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "close_bracket" + }, + "to": [ + { + "key_code": "close_bracket", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + } + ], + "from": { + "key_code": "right_option", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "set_variable": { + "key_up_value": 0, + "name": "layer", + "value": 1 + } + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "type": "basic" + } + ] + }, + { + "description": "Raise Layer", + "manipulators": [ + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "a", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "a", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "a", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "a", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "s", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "s", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "s", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "s", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "down_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "w", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "w", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "w", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "w", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "up_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "d", + "modifiers": { + "mandatory": [ + "command", + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow", + "modifiers": [ + "command", + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "d", + "modifiers": { + "mandatory": [ + "command" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow", + "modifiers": [ + "option" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "d", + "modifiers": { + "mandatory": [ + "option" + ], + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow", + "modifiers": [ + "command" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "d", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_arrow" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "q", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "home" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "e", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "end" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "r", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "page_up" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "f", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "page_down" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "z" + }, + "to": [ + { + "key_code": "grave_accent_and_tilde" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "x" + }, + "to": [ + { + "key_code": "grave_accent_and_tilde", + "modifiers": [ + "shift" + ] + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + } + ], + "from": { + "key_code": "right_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "set_variable": { + "key_up_value": 0, + "name": "layer", + "value": 2 + } + } + ], + "type": "basic" + } + ] + }, + { + "description": "MacBook Internal Keyboard", + "manipulators": [ + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + }, + { + "identifiers": [ + { + "vendor_id": 1452 + } + ], + "type": "device_if" + } + ], + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "set_variable": { + "key_up_value": 0, + "name": "layer", + "value": 1 + } + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "type": "basic" + } + ] + }, + { + "description": "REALFORCE", + "manipulators": [ + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 0 + }, + { + "identifiers": [ + { + "product_id": 4, + "vendor_id": 11240 + } + ], + "type": "device_exists_if" + }, + { + "identifiers": [ + { + "product_id": 328, + "vendor_id": 2131 + } + ], + "type": "device_if" + } + ], + "from": { + "key_code": "spacebar", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "set_variable": { + "key_up_value": 0, + "name": "layer", + "value": 1 + } + } + ], + "to_if_alone": [ + { + "key_code": "return_or_enter" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "identifiers": [ + { + "product_id": 4, + "vendor_id": 11240 + } + ], + "type": "device_exists_if" + }, + { + "identifiers": [ + { + "product_id": 328, + "vendor_id": 2131 + } + ], + "type": "device_if" + } + ], + "from": { + "key_code": "b", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "delete_or_backspace" + } + ], + "type": "basic" + } + ] + }, + { + "description": "JA tsrngn", + "manipulators": [ + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "r", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "d" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "t", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "l" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "y", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "v" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "u", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "y" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "i", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "r" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "o", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "j" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "s", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "u" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "d", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "o" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "f", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "i" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "j", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "t" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "k", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "s" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "l", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "k" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "semicolon", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "comma" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "quote", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "period" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "v", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "f" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "comma", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "hyphen" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "period", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "semicolon" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + }, + { + "input_sources": [ + { + "language": "ja" + } + ], + "type": "input_source_if" + } + ], + "from": { + "key_code": "hyphen", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "quote" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "r", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "d" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "t", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "l" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "y", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "v" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "u", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "y" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "i", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "r" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "o", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "j" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "s", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "u" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "d", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "o" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "f", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "i" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "j", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "t" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "k", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "s" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "l", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "k" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "semicolon", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "comma" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "quote", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "period" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "v", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "f" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "comma", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "hyphen" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "period", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "semicolon" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "hyphen", + "modifiers": { + "optional": [ + "shift" + ] + } + }, + "to": [ + { + "key_code": "quote" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "page_up" + }, + "parameters": { + "basic.to_delayed_action_delay_milliseconds": 2000 + }, + "to": [ + { + "set_variable": { + "name": "tsrngn", + "value": 0 + } + }, + { + "set_notification_message": { + "id": "tsrngn", + "text": "QWERTY MODE" + } + } + ], + "to_delayed_action": { + "to_if_canceled": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ], + "to_if_invoked": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ] + }, + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + }, + { + "name": "tsrngn", + "type": "variable_if", + "value": 2 + } + ], + "from": { + "key_code": "page_down" + }, + "parameters": { + "basic.to_delayed_action_delay_milliseconds": 2000 + }, + "to": [ + { + "set_variable": { + "name": "tsrngn", + "value": 0 + } + }, + { + "set_notification_message": { + "id": "tsrngn", + "text": "QWERTY MODE" + } + } + ], + "to_delayed_action": { + "to_if_canceled": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ], + "to_if_invoked": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ] + }, + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + }, + { + "name": "tsrngn", + "type": "variable_if", + "value": 0 + } + ], + "from": { + "key_code": "page_down" + }, + "parameters": { + "basic.to_delayed_action_delay_milliseconds": 2000 + }, + "to": [ + { + "set_variable": { + "name": "tsrngn", + "value": 1 + } + }, + { + "set_notification_message": { + "id": "tsrngn", + "text": "TSRNGN MODE" + } + } + ], + "to_delayed_action": { + "to_if_canceled": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ], + "to_if_invoked": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ] + }, + "type": "basic" + }, + { + "conditions": [ + { + "name": "layer", + "type": "variable_if", + "value": 2 + }, + { + "name": "tsrngn", + "type": "variable_if", + "value": 1 + } + ], + "from": { + "key_code": "page_down" + }, + "parameters": { + "basic.to_delayed_action_delay_milliseconds": 2000 + }, + "to": [ + { + "set_variable": { + "name": "tsrngn", + "value": 2 + } + }, + { + "set_notification_message": { + "id": "tsrngn", + "text": "FULL TSRNGN MODE" + } + } + ], + "to_delayed_action": { + "to_if_canceled": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ], + "to_if_invoked": [ + { + "set_notification_message": { + "id": "tsrngn", + "text": "" + } + } + ] + }, + "type": "basic" + } + ] + } + ] }, "devices": [ { @@ -506,25 +3822,71 @@ }, { "from": { - "key_code": "right_command" + "key_code": "right_option" }, "to": [ { - "key_code": "japanese_eisuu" + "key_code": "fn" + } + ] + } + ], + "treat_as_built_in_keyboard": false + }, + { + "disable_built_in_keyboard_if_exists": false, + "fn_function_keys": [], + "identifiers": { + "is_keyboard": true, + "is_pointing_device": false, + "product_id": 4, + "vendor_id": 11240 + }, + "ignore": false, + "manipulate_caps_lock_led": true, + "simple_modifications": [ + { + "from": { + "key_code": "escape" + }, + "to": [ + { + "key_code": "grave_accent_and_tilde" } ] }, { "from": { - "key_code": "right_option" + "key_code": "left_command" }, "to": [ { - "key_code": "fn" + "key_code": "left_control" + } + ] + }, + { + "from": { + "key_code": "left_control" + }, + "to": [ + { + "key_code": "left_command" + } + ] + }, + { + "from": { + "key_code": "right_control" + }, + "to": [ + { + "key_code": "japanese_eisuu" } ] } - ] + ], + "treat_as_built_in_keyboard": false }, { "disable_built_in_keyboard_if_exists": false, @@ -532,12 +3894,22 @@ "identifiers": { "is_keyboard": true, "is_pointing_device": false, - "product_id": 4438, - "vendor_id": 51984 + "product_id": 328, + "vendor_id": 2131 }, "ignore": false, - "manipulate_caps_lock_led": false, + "manipulate_caps_lock_led": true, "simple_modifications": [ + { + "from": { + "key_code": "keypad_num_lock" + }, + "to": [ + { + "key_code": "vk_none" + } + ] + }, { "from": { "key_code": "left_command" @@ -557,8 +3929,19 @@ "key_code": "left_command" } ] + }, + { + "from": { + "key_code": "right_command" + }, + "to": [ + { + "key_code": "right_control" + } + ] } - ] + ], + "treat_as_built_in_keyboard": false }, { "disable_built_in_keyboard_if_exists": false, @@ -566,12 +3949,22 @@ "identifiers": { "is_keyboard": true, "is_pointing_device": false, - "product_id": 4, - "vendor_id": 11240 + "product_id": 0, + "vendor_id": 65261 }, "ignore": false, - "manipulate_caps_lock_led": false, + "manipulate_caps_lock_led": true, "simple_modifications": [ + { + "from": { + "key_code": "left_command" + }, + "to": [ + { + "key_code": "left_control" + } + ] + }, { "from": { "key_code": "left_control" @@ -581,6 +3974,31 @@ "key_code": "left_command" } ] + } + ], + "treat_as_built_in_keyboard": false + }, + { + "disable_built_in_keyboard_if_exists": false, + "fn_function_keys": [], + "identifiers": { + "is_keyboard": true, + "is_pointing_device": false, + "product_id": 591, + "vendor_id": 1452 + }, + "ignore": false, + "manipulate_caps_lock_led": true, + "simple_modifications": [ + { + "from": { + "key_code": "escape" + }, + "to": [ + { + "key_code": "grave_accent_and_tilde" + } + ] }, { "from": { @@ -594,25 +4012,26 @@ }, { "from": { - "key_code": "right_option" + "key_code": "left_control" }, "to": [ { - "key_code": "escape" + "key_code": "left_command" } ] }, { "from": { - "key_code": "right_control" + "key_code": "right_option" }, "to": [ { - "key_code": "japanese_eisuu" + "key_code": "right_command" } ] } - ] + ], + "treat_as_built_in_keyboard": false } ], "fn_function_keys": [ @@ -735,16 +4154,6 @@ "consumer_key_code": "volume_increment" } ] - }, - { - "from": { - "key_code": "japanese_eisuu" - }, - "to": [ - { - "key_code": "japanese_kana" - } - ] } ], "name": "Default profile", diff --git a/config/karabiner/karabiner.ts b/config/karabiner/karabiner.ts new file mode 100755 index 0000000..b522790 --- /dev/null +++ b/config/karabiner/karabiner.ts @@ -0,0 +1,419 @@ +#!/usr/bin/env -S deno run --check --allow-write +import { + BasicManipulatorBuilder, + complexModifications, + defaultGlobals, + device, + FromKeyCode, + ifDevice, + ifDeviceExists, + ifInputSource, + ifVar, + KarabinerConfigExt, + KarabinerProfileExt, + KeyboardIdentifier, + map, + rule, + saveConfig, + simpleModifications, + stroke, + toRemoveNotificationMessage, + toSetVar, + withCondition, + withMapper, +} from "./utils.ts"; + +const DEVICES = { + apple: { + vendor_id: 1452, + }, + macBook2018: { + product_id: 634, + vendor_id: 1452, + }, + progresTouchRetroTiny: { + product_id: 4, + vendor_id: 11240, + }, + realforceR2: { + product_id: 328, + vendor_id: 2131, + }, + mint60: { + product_id: 0, + vendor_id: 65261, + }, + akl680: { + product_id: 591, + vendor_id: 1452, + }, +} as const satisfies Record; + +const LAYER_VAR = "layer"; + +const LAYERS = { + normal: 0, + lower: 1, + raise: 2, +} as const; + +type Layer = keyof typeof LAYERS; + +function ifLayer(layer: Layer) { + return ifVar(LAYER_VAR, LAYERS[layer]); +} + +function toMOLayer(layer: Layer) { + return toSetVar(LAYER_VAR, LAYERS[layer], LAYERS.normal); +} + +function backspaceRule() { + return rule( + "Exchange Command+Backspace/Delete and Option+Backspace/Delete", + ).manipulators([ + withCondition(ifLayer("normal"))([ + map("⌫", "command", "shift").to("⌫", "option"), + map("⌫", "option", "shift").to("⌫", "command"), + map("⌦", "command", "shift").to("⌦", "option"), + map("⌦", "option", "shift").to("⌦", "command"), + ]), + withCondition(ifLayer("lower"))([ + map("⌫", "command", "shift").to("⌦", "option"), + map("⌫", "option", "shift").to("⌦", "command"), + map("⌫", null, "any").to("⌦"), + ]), + withCondition(ifLayer("raise"))([ + map("⌫", "command", "shift").to("⌦", "option"), + map("⌫", "option", "shift").to("⌦", "command"), + map("⌫", null, "any").to("⌦"), + ]), + ]); +} + +const arrowKeys = ["←", "↓", "↑", "→"] as const; + +function modArrowRule() { + return rule( + "Exchange command + arrow keys with option + arrow keys", + ).manipulators( + arrowKeys.flatMap((key) => [ + map(key, ["command", "option"], "any").to(key, ["command", "option"]), + map(key, "command", "any").to(key, "option"), + map(key, "option", "any").to(key, "command"), + ]), + ); +} + +function mapArrows( + up: FromKeyCode, + left: FromKeyCode, + down: FromKeyCode, + right: FromKeyCode, +) { + const alt = [left, down, up, right]; + return arrowKeys.flatMap((key, i) => [ + map(alt[i], ["command", "option"], "any").to(key, ["command", "option"]), + map(alt[i], "command", "any").to(key, "option"), + map(alt[i], "option", "any").to(key, "command"), + map(alt[i], null, "any").to(key), + ]); +} + +function capsLockRule() { + return rule("Change Caps Lock").manipulators([ + map("caps_lock", "shift") + .to("left_command", "shift") + .toIfAlone(stroke("->")), + map("caps_lock", "command") + .to("left_command", "shift") + .toIfAlone(stroke("=>")), + map("caps_lock") + .condition(ifLayer("lower")) + .to("left_command", "shift") + .toIfAlone(stroke("-")), + map("caps_lock", null, "any") + .to("left_command", "shift") + .toIfAlone(stroke("_")), + ]); +} + +function lowerRule() { + return rule("Lower Layer").manipulators([ + withCondition(ifLayer("lower"))([ + map("1").to(stroke("!")), + map("2").to(stroke("@")), + map("3").to(stroke("#")), + map("4").to(stroke("$")), + map("5").to(stroke("%")), + + map("6").to(stroke("^")), + map("7").to(stroke("&")), + map("8").to(stroke("*")), + map("9").to(stroke("(")), + map("0").to(stroke(")")), + map("-").to(stroke("_")), + map("=").to(stroke("+")), + + map("q").to(stroke("!")), + map("w").to(stroke("@")), + map("e").to(stroke("#")), + map("r").to(stroke("$")), + map("t").to(stroke("%")), + + map("a").to(stroke("^")), + map("s").to(stroke("&")), + map("d").to(stroke("*")), + map("f").to(stroke("=")), + map("g").to(stroke("+")), + + ...mapArrows("i", "j", "k", "l"), + map("u", null, "any").to("home"), + map("o", null, "any").to("end"), + map("p", null, "any").to("page_up"), + map(";", null, "any").to("page_down"), + + map("z").to(stroke("(")), + map("x").to(stroke(")")), + map("c").to(stroke("/")), + map("v").to(stroke("?")), + + map("[").to(stroke("{")), + map("]").to(stroke("}")), + ]), + map("right_option", null, "any") + .condition(ifLayer("normal")) + .to(toMOLayer("lower")) + .toIfAlone("escape"), + ]); +} + +function raiseRule() { + return rule("Raise Layer").manipulators([ + withCondition(ifLayer("raise"))([ + ...mapArrows("w", "a", "s", "d"), + map("q", null, "any").to("home"), + map("e", null, "any").to("end"), + map("r", null, "any").to("page_up"), + map("f", null, "any").to("page_down"), + + map("z").to(stroke("`")), + map("x").to(stroke("~")), + ]), + map("right_control", null, "any") + .condition(ifLayer("normal")) + .to(toMOLayer("raise")), + ]); +} + +function macRule() { + return rule("MacBook Internal Keyboard") + .condition(ifDevice(DEVICES.apple)) + .manipulators([ + map("right_command", null, "any") + .condition(ifLayer("normal")) + .to(toMOLayer("lower")) + .toIfAlone("escape"), + ]); +} + +function realforceRule() { + return rule("REALFORCE") + .condition(ifDevice(DEVICES.realforceR2)) + .manipulators([ + withCondition(ifDeviceExists(DEVICES.progresTouchRetroTiny))([ + map("spacebar", null, "any") + .condition(ifLayer("normal")) + .to(toMOLayer("lower")) + .toIfAlone("return_or_enter"), + map("b", null, "any") + .to("delete_or_backspace"), + ]), + ]); +} + +const tsrngnMap = { + q: "q", + w: "w", + e: "e", + r: "d", + t: "l", + y: "v", + u: "y", + i: "r", + o: "j", + p: "p", + "[": "[", + "]": "]", + "\\": "\\", + + a: "a", + s: "u", + d: "o", + f: "i", + g: "g", + h: "h", + j: "t", + k: "s", + l: "k", + ";": ",", + "'": ".", + + z: "z", + x: "x", + c: "c", + v: "f", + b: "b", + n: "n", + m: "m", + ",": "-", + ".": ";", + "/": "/", + "-": "'", +} as const; + +function tsrngnRule() { + const modeVar = "tsrngn"; + + function remapKeys() { + const keyMap = Object.fromEntries( + Object.entries(tsrngnMap).filter(([from, to]) => from !== to), + ) as Partial; + + return withMapper(keyMap)((from, to) => map(from, null, "shift").to(to)); + } + + enum Mode { + off, + ja, + full, + } + + function switchMode(mode: Mode, message: string, m: BasicManipulatorBuilder) { + return m + .toVar(modeVar, mode) + .parameters({ "basic.to_delayed_action_delay_milliseconds": 2000 }) + .toNotificationMessage(modeVar, message) + .toDelayedAction( + toRemoveNotificationMessage(modeVar), + toRemoveNotificationMessage(modeVar), + ); + } + + return rule("JA tsrngn").manipulators([ + withCondition( + ifVar(modeVar, 1), + ifInputSource({ language: "ja" }), + )([remapKeys()]), + withCondition(ifVar(modeVar, 2))([remapKeys()]), + switchMode( + Mode.off, + "QWERTY MODE", + map("page_up").condition(ifLayer("raise")), + ), + switchMode( + Mode.off, + "QWERTY MODE", + map("page_down").condition(ifLayer("raise"), ifVar(modeVar, Mode.full)), + ), + switchMode( + Mode.ja, + "TSRNGN MODE", + map("page_down").condition(ifLayer("raise"), ifVar(modeVar, Mode.off)), + ), + switchMode( + Mode.full, + "FULL TSRNGN MODE", + map("page_down").condition(ifLayer("raise"), ifVar(modeVar, Mode.ja)), + ), + ]); +} + +const profile: KarabinerProfileExt = { + complex_modifications: complexModifications( + [ + backspaceRule(), + modArrowRule(), + capsLockRule(), + lowerRule(), + raiseRule(), + macRule(), + realforceRule(), + tsrngnRule(), + ], + { + "basic.to_if_alone_timeout_milliseconds": 250, + "basic.to_if_held_down_threshold_milliseconds": 250, + }, + ), + devices: [ + device(DEVICES.macBook2018, { + simple_modifications: simpleModifications([ + map("fn").to("left_command"), + map("left_command").to("escape"), + map("right_option").to("fn"), + ]), + }), + device(DEVICES.progresTouchRetroTiny, { + simple_modifications: simpleModifications([ + map("escape").to("grave_accent_and_tilde"), + map("left_command").to("left_control"), + map("left_control").to("left_command"), + map("right_control").to("japanese_eisuu"), + ]), + }), + device(DEVICES.realforceR2, { + simple_modifications: simpleModifications([ + map("keypad_num_lock").toNone(), + map("left_command").to("left_control"), + map("left_control").to("left_command"), + map("right_command").to("right_control"), + ]), + }), + device(DEVICES.mint60, { + simple_modifications: simpleModifications([ + map("left_command").to("left_control"), + map("left_control").to("left_command"), + ]), + }), + device(DEVICES.akl680, { + simple_modifications: simpleModifications([ + map("escape").to("grave_accent_and_tilde"), + map("left_command").to("left_control"), + map("left_control").to("left_command"), + map("right_option").to("right_command"), + ]), + }), + ], + fn_function_keys: simpleModifications([ + map("f1").toConsumerKey("display_brightness_decrement"), + map("f2").toConsumerKey("display_brightness_increment"), + map("f3").to("mission_control"), + map("f4").to("launchpad"), + map("f5").to("illumination_decrement"), + map("f6").to("illumination_increment"), + map("f7").toConsumerKey("rewind"), + map("f8").toConsumerKey("play_or_pause"), + map("f9").toConsumerKey("fastforward"), + map("f10").toConsumerKey("mute"), + map("f11").toConsumerKey("volume_decrement"), + map("f12").toConsumerKey("volume_increment"), + ]), + name: "Default profile", + parameters: { + delay_milliseconds_before_open_device: 1000, + }, + selected: true, + simple_modifications: [], + virtual_hid_keyboard: { + country_code: 0, + indicate_sticky_modifier_keys_state: true, + mouse_key_xy_scale: 100, + }, +}; + +const config: KarabinerConfigExt = { + global: defaultGlobals, + profiles: [profile], +}; + +await saveConfig(new URL("karabiner.json", import.meta.url), config); diff --git a/config/karabiner/utils.ts b/config/karabiner/utils.ts new file mode 100644 index 0000000..48fccd1 --- /dev/null +++ b/config/karabiner/utils.ts @@ -0,0 +1,142 @@ +export * from "https://deno.land/x/karabinerts/deno.ts"; +export { BasicManipulatorBuilder } from "https://deno.land/x/karabinerts/config/manipulator.ts"; + +import { + DeviceIdentifier, + FromEvent, + KarabinerProfile, + ToEvent, + toKey, +} from "https://deno.land/x/karabinerts/deno.ts"; +import { BasicManipulatorBuilder } from "https://deno.land/x/karabinerts/config/manipulator.ts"; + +export interface SimpleManipulator { + from: FromEvent; + to?: ToEvent[]; +} + +export type SimpleModifications = SimpleManipulator[]; + +export type KarabinerGlobal = Record; + +export interface KarabinerDevice { + disable_built_in_keyboard_if_exists: boolean; + fn_function_keys: SimpleModifications; + identifiers: DeviceIdentifier; + ignore: boolean; + manipulate_caps_lock_led: boolean; + simple_modifications: SimpleModifications; + treat_as_built_in_keyboard: boolean; +} + +export interface KarabinerProfileExt extends KarabinerProfile { + devices: KarabinerDevice[]; + fn_function_keys: SimpleModifications; + parameters: Record; + simple_modifications: SimpleModifications; + virtual_hid_keyboard: Record; +} + +export interface KarabinerConfigExt { + global: KarabinerGlobal; + profiles: KarabinerProfileExt[]; +} + +export const defaultGlobals: KarabinerGlobal = { + ask_for_confirmation_before_quitting: true, + check_for_updates_on_startup: true, + show_in_menu_bar: true, + show_profile_name_in_menu_bar: false, + unsafe_ui: false, +}; + +export function simpleModifications( + builders: BasicManipulatorBuilder[], +): SimpleModifications { + return builders + .flatMap((builder) => builder.build()) + .map((m) => ({ ...m, type: undefined })); +} + +const keyAliases = { + "-": toKey("-"), + _: toKey("-", "shift"), + "=": toKey("="), + "+": toKey("=", "shift"), + ">": toKey(".", "shift"), + "/": toKey("/"), + "?": toKey("/", "shift"), + "!": toKey("1", "shift"), + "@": toKey("2", "shift"), + "#": toKey("3", "shift"), + $: toKey("4", "shift"), + "%": toKey("5", "shift"), + "^": toKey("6", "shift"), + "&": toKey("7", "shift"), + "*": toKey("8", "shift"), + "(": toKey("9", "shift"), + ")": toKey("0", "shift"), + "{": toKey("[", "shift"), + "}": toKey("]", "shift"), + '"': toKey("'", "shift"), + "`": toKey("`"), + "~": toKey("`", "shift"), +} as const satisfies Record; + +type KeyAlias = keyof typeof keyAliases; + +export function stroke(text: string): ToEvent[] { + return [...text].map( + (c): ToEvent => + keyAliases[c as KeyAlias] ?? + (() => { + throw new Error(`unknown character '${c}'`); + })(), + ); +} + +export type KeyboardIdentifier = { + product_id?: number; + vendor_id: number; +}; + +export function device( + keyboard: KeyboardIdentifier, + settings: Pick, +): KarabinerDevice { + return { + identifiers: { + is_keyboard: true, + is_pointing_device: false, + ...keyboard, + }, + disable_built_in_keyboard_if_exists: false, + ignore: false, + manipulate_caps_lock_led: true, + treat_as_built_in_keyboard: false, + fn_function_keys: [], + ...settings, + }; +} + +export async function saveConfig(path: URL, config: KarabinerConfigExt) { + await Deno.writeTextFile( + path, + JSON.stringify( + config, + (_key, value) => { + if ( + typeof value === "object" && + value !== null && + !Array.isArray(value) + ) { + return Object.fromEntries( + Object.entries(value).sort(([ak], [bk]) => ak.localeCompare(bk)), + ); + } + return value; + }, + 4, + ), + ); +}