Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language switching utility function #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
};
}