diff --git a/types.ts b/types.ts index 7fa321b7..b2f625b2 100644 --- a/types.ts +++ b/types.ts @@ -121,6 +121,9 @@ export interface To { * @see: {@link https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to/software_function/iokit_power_management_sleep_system/} */ software_function?: SoftwareFunction; + select_input_source?: { + language: string; + }; } export interface MouseKey { diff --git a/utils.ts b/utils.ts index 8517836e..cc5ace32 100644 --- a/utils.ts +++ b/utils.ts @@ -211,3 +211,19 @@ export function rectangle(name: string): LayerCommand { export function app(name: string): LayerCommand { return open(`-a '${name}.app'`); } + +/** + * Shortcut for "switching to a language" command + */ +export function switchToLanguage(languageCode: string): LayerCommand { + return { + to: [ + { + select_input_source: { + language: languageCode, + }, + }, + ], + description: `Switch keyboard language to ${languageCode}`, + }; +}