Skip to content

Instantly share code, notes, and snippets.

@obfischer
Created January 30, 2022 09:38
Show Gist options
  • Save obfischer/b2c902997ae7775fb4e63f67707ba80f to your computer and use it in GitHub Desktop.
Save obfischer/b2c902997ae7775fb4e63f67707ba80f to your computer and use it in GitHub Desktop.
Generate Karabiner Elements configuration out of y YAML document
set -x
cat karabiner.yaml | ruby -r yaml -r json -e 'puts YAML.load($stdin.read).to_json' \
| jq --sort-keys 'del(.definitions)' > karabiner.json
definitions:
device:
hdmi_kvm_keyboard:
vendor: &hdmi_kvm_vendor 1367
product_id: &hdmi_kvm_product_id 8750
device_selectors:
- &wenn_an_kvm_angeschlossen
type: device_if
identifiers:
- description: Tastatur am ATEN KVM Switch CS 1844
vendor_id: *hdmi_kvm_vendor
product_id: *hdmi_kvm_product_id
is_keyboard: true
virtual_hid_keyboard: &globales_vir_hid_keyboard
caps_lock_delay_milliseconds: 0
country_code: 0
indicate_sticky_modifier_keys_state: true
keyboard_type: ansi
mouse_key_xy_scale: 100
complex_modifications:
parameters: &globale_komplexe_modifikationen_parameter
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
mouse_motion_to_scroll.speed: 100
rules:
- &msteams_play_toogle_video
description: Bei MS Teams über play_or_pause zum togglen von Kamera
manipulators:
- type: basic
from:
key_code: "play_or_pause"
to:
key_code: "o"
modifiers:
- left_command
- left_shift
conditions:
- type: frontmost_application_if
bundle_identifiers:
- "^com\\.microsoft\\.teams$"
- &msteams_play_toogle_audio
description: Bei MS Teams über play_or_pause zum togglen von Kamera
manipulators:
- type: basic
from:
key_code: "mute"
to:
key_code: "m"
modifiers:
- left_command
- left_shift
conditions:
- type: frontmost_application_if
bundle_identifiers:
- "^com\\.microsoft\\.teams$"
- &thunderbird_f5_mail_rot_markieren
description: Bei Thunderbird mit F5 die aktuelle Mail rot markieren
manipulators:
- type: basic
from:
key_code: "f5"
to:
- key_code: "r" # Markiere Mail als gelesen
- key_code: "0" # Markiere die Mail als rot
- key_code: "1" # Markiere die Mail als rot
- key_code: "n" # Gehe zur nächsten Mail
conditions:
- type: frontmost_application_if
bundle_identifiers:
- "^org\\.mozilla\\.thunderbird$"
- &thunderbird_f6_mail_gelesen_markieren
description: Bei Thunderbird mit F6 die aktuelle Mail als gelesen markieren
manipulators:
- type: basic
from:
key_code: "f6"
to:
- key_code: "r" # Markiere Mail als gelesen
- key_code: "0" # Markierungen entfernen
- key_code: "n" # Gehe zur nächsten Mail
conditions:
- type: frontmost_application_if
bundle_identifiers:
- "^org\\.mozilla\\.thunderbird$"
- &thunderbird_f7_mail_gelesen_und_archivieren
description: Bei Thunderbird mit F7 die aktuelle Mail als gelesen markieren und archivieren
manipulators:
- type: basic
from:
key_code: "f7"
to:
- key_code: "r" # Markiere Mail als gelesen
- key_code: "0" # Markierungen entfernen
- key_code: "a" # archivieren
conditions:
- type: frontmost_application_if
bundle_identifiers:
- "^org\\.mozilla\\.thunderbird$"
- &regel_application
description: "Application auf Maus-Button 2"
manipulators:
- type: basic
from:
key_code: application
to:
pointing_button: button2
- &regel_gravis
description: "Gravis \"`\" mittels Hochstelltaste links und `"
manipulators:
- type: basic
from:
key_code: equal_sign
modifiers:
mandatory:
- left_shift
to:
- key_code: equal_sign
modifiers:
- left_shift
- key_code: spacebar
- &regel_eckige_klammer_auf
description: "Eckige öffnende Klammer \"[\", wenn Cmd + i"
manipulators:
- type: basic
from:
key_code: i
modifiers:
mandatory:
- left_command
- right_shift
to:
- key_code: "5"
modifiers:
- right_option
- &regel_eckige_klammer_zu
description: "Eckige schließende Klammer \"]\", wenn Cmd + o"
manipulators:
- type: basic
from:
key_code: "o"
modifiers:
mandatory:
- left_command
- right_shift
to:
- key_code: "6"
modifiers:
- left_option
- &regel_geschweifte_klammer_auf
description: "Geschweifte öffnende Klammer \"{\", wenn Cmd + k"
manipulators:
- type: basic
from:
key_code: "k"
modifiers:
mandatory:
- left_command
- right_shift
to:
- key_code: "8"
modifiers:
- left_option
- &regel_geschweifte_klammer_zu
description: "Geschweifte schließende Klammer \"}\", wenn Cmd + l"
manipulators:
- type: basic
from:
key_code: "l"
modifiers:
mandatory:
- left_command
- right_shift
to:
- key_code: "9"
modifiers:
- left_option
global:
check_for_updates_on_startup: true
show_in_menu_bar: true
show_profile_name_in_menu_bar: true
profiles:
- name: "Leeres Profil"
- name: "Externe Tastatur ISO/DE"
selected: true
parameters: &globale_parameter
delay_milliseconds_before_open_device: 1000
complex_modifications:
parameters:
<<: *globale_komplexe_modifikationen_parameter
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
mouse_motion_to_scroll.speed: 100
rules:
- *regel_gravis
- *regel_eckige_klammer_auf
- *regel_eckige_klammer_zu
- *regel_geschweifte_klammer_auf
- *regel_geschweifte_klammer_zu
- *regel_application
- *thunderbird_f5_mail_rot_markieren
- *thunderbird_f6_mail_gelesen_markieren
- *thunderbird_f7_mail_gelesen_und_archivieren
- *msteams_play_toogle_video
- *msteams_play_toogle_audio
simple_modifications:
- from:
key_code: left_option
to:
key_code: left_command
- from:
key_code: left_command
to:
key_code: left_option
- from:
key_code: right_option
to:
key_code: right_command
- from:
key_code: right_command
to:
key_code: right_option
virtual_hid_keyboard:
<<: *globales_vir_hid_keyboard
- name: "Apple Keyboard"
parameters:
<<: *globale_parameter
virtual_hid_keyboard:
<<: *globales_vir_hid_keyboard
complex_modifications:
parameters:
<<: *globale_komplexe_modifikationen_parameter
rules:
- *regel_gravis
- *regel_eckige_klammer_auf
- *regel_eckige_klammer_zu
- *regel_geschweifte_klammer_auf
- *regel_geschweifte_klammer_zu
@muescha
Copy link

muescha commented Aug 15, 2022

type as yaml
cat karabiner.json | ruby -r yaml -r json -e 'puts JSON.load($stdin.read).to_yaml'

convert to yaml
cat karabiner.json | ruby -r yaml -r json -e 'puts JSON.load($stdin.read).to_yaml' > karabiner.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment