From 178665cf0e541029117e880765f76a328b77e5de Mon Sep 17 00:00:00 2001 From: Michael David Kuckuk <8076094+LBBO@users.noreply.github.com> Date: Thu, 13 Jun 2024 09:05:45 +0200 Subject: [PATCH] Add language switching utility --- types.ts | 3 +++ utils.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/types.ts b/types.ts index 7fa321b..b2f625b 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 8517836..cc5ace3 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}`, + }; +}