Skip to content

Commit

Permalink
✨ Add support for set_variable.key_up_value (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryooooooga authored Jul 9, 2024
1 parent ee710bc commit 32f15ce
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/config/manipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ export class BasicManipulatorBuilder implements ManipulatorBuilder {
}

/** Map to setting a variable */
toVar(name: string, value: ToVariable['value'] = 1): this {
this.addToEvent(toSetVar(name, value))
toVar(
name: string,
value: ToVariable['value'] = 1,
key_up_value?: ToVariable['key_up_value'],
): this {
this.addToEvent(toSetVar(name, value, key_up_value))
return this
}

Expand Down
3 changes: 3 additions & 0 deletions src/config/to.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ test('setVar()', () => {
expect(toSetVar('test', true)).toEqual({
set_variable: { name: 'test', value: true },
})
expect(toSetVar('test', true, false)).toEqual({
set_variable: { name: 'test', value: true, key_up_value: false },
})
})

test('toPlaySound()', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/config/to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ export function toInputSource(inputSource: ToInputSource): ToEvent {
export function toSetVar(
name: string,
value: ToVariable['value'] = 1,
key_up_value?: ToVariable['key_up_value'],
): ToEvent {
return { set_variable: { name, value } }
return { set_variable: { name, value, key_up_value } }
}

/** Create ToEvent with set_notification_message */
Expand Down
1 change: 1 addition & 0 deletions src/karabiner/karabiner-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type ToInputSource = {
export type ToVariable = {
name: string
value: number | boolean | string
key_up_value?: number | boolean | string
}

/** @see https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to/mouse-key/ */
Expand Down

0 comments on commit 32f15ce

Please sign in to comment.