Skip to content

Instantly share code, notes, and snippets.

@nup002
Last active August 28, 2025 20:19
Show Gist options
  • Save nup002/ca1a680b2051f7bafdd26f2cd096d80a to your computer and use it in GitHub Desktop.
Save nup002/ca1a680b2051f7bafdd26f2cd096d80a to your computer and use it in GitHub Desktop.
{
"title": "Unicode Keypad Processor",
"rules": [
{
"description": "Unicode hex input with Option key",
"manipulators": [
// Handle Left Option key - convert and type on release
{
"type": "basic",
"from": {
"key_code": "left_option"
},
"to": [
{ "key_code": "vk_none" }
],
"to_after_key_up": [
{
"shell_command": "if [ -f '/tmp/hex_sequence' ]; then hex_sequence=$(cat /tmp/hex_sequence); echo \"Processing hex: [$hex_sequence]\" >> /tmp/karabiner_debug.log; if [ -n \"$hex_sequence\" ]; then padded_hex=$(printf '%08s' \"$hex_sequence\" | tr ' ' '0'); printf \"\\\\U$padded_hex\" | pbcopy && osascript -e 'tell application \"System Events\" to keystroke (the clipboard as text)' && echo \"Typed Unicode for hex: $hex_sequence (padded: $padded_hex)\" >> /tmp/karabiner_debug.log; fi; fi"
},
{ "shell_command": "rm -f /tmp/hex_sequence" }
],
"conditions": [
{
"type": "device_if",
"identifiers": [
{
"vendor_id": 4617,
"product_id": 8721
}
]
}
]
},
// Hex digits 0-9
{
"type": "basic",
"from": { "key_code": "0" },
"to": [
{ "shell_command": "echo -n '0' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "1" },
"to": [
{ "shell_command": "echo -n '1' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "2" },
"to": [
{ "shell_command": "echo -n '2' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "3" },
"to": [
{ "shell_command": "echo -n '3' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "4" },
"to": [
{ "shell_command": "echo -n '4' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "5" },
"to": [
{ "shell_command": "echo -n '5' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "6" },
"to": [
{ "shell_command": "echo -n '6' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "7" },
"to": [
{ "shell_command": "echo -n '7' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "8" },
"to": [
{ "shell_command": "echo -n '8' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "9" },
"to": [
{ "shell_command": "echo -n '9' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
// Hex letters a-f
{
"type": "basic",
"from": { "key_code": "a" },
"to": [
{ "shell_command": "echo -n 'a' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "b" },
"to": [
{ "shell_command": "echo -n 'b' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "c" },
"to": [
{ "shell_command": "echo -n 'c' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "d" },
"to": [
{ "shell_command": "echo -n 'd' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "e" },
"to": [
{ "shell_command": "echo -n 'e' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
},
{
"type": "basic",
"from": { "key_code": "f" },
"to": [
{ "shell_command": "echo -n 'f' >> /tmp/hex_sequence" }
],
"conditions": [
{ "type": "device_if", "identifiers": [{ "vendor_id": 4617, "product_id": 8721 }] }
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment