Skip to content
Merged
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
28 changes: 28 additions & 0 deletions packages/remote-input/src/backends/waylandYdotool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,34 @@
expect(run).toHaveBeenCalledWith('ydotool', ['type', 'a']);
});

it('uses the detected ydotool binary for text input', async () => {
const run = vi.fn().mockResolvedValue(undefined);
const backend = new WaylandYdotoolInputBackend(run, {
hasBinary: true,
binaryPath: '/opt/pairux/ydotool',
hasSocket: true,
socketPath: '/tmp/.ydotool_socket',
});

await backend.inject({
type: 'keyboard',
action: 'press',
key: 'a',
code: 'KeyA',
modifiers: { ctrl: false, alt: false, shift: false, meta: false },
});
await backend.inject({
type: 'keyboard',
action: 'press',
key: '🙂',
code: 'Unidentified',
modifiers: { ctrl: false, alt: false, shift: false, meta: false },
});

expect(run).toHaveBeenNthCalledWith(1, '/opt/pairux/ydotool', ['type', 'a']);
expect(run).toHaveBeenNthCalledWith(2, '/opt/pairux/ydotool', ['type', '🙂']);
});

it('emits key sequence for modified shortcut', async () => {
const run = vi.fn().mockResolvedValue(undefined);
const backend = new WaylandYdotoolInputBackend(run, {
Expand Down
4 changes: 2 additions & 2 deletions packages/remote-input/src/backends/waylandYdotool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,13 @@ export class WaylandYdotoolInputBackend implements InputBackend {
const modifiers = modifierKeycodes(event.modifiers);

if (event.action === 'press' && modifiers.length === 0 && event.key.length === 1) {
await this.run('ydotool', ['type', event.key]);
await this.run(this.ydotoolCommand, ['type', event.key]);
return;
}

if (keycode == null) {
if (event.action === 'press' && event.key.length > 0) {
await this.run('ydotool', ['type', event.key]);
await this.run(this.ydotoolCommand, ['type', event.key]);
return;
}
throw new Error(`Unsupported key for ydotool backend: ${event.key} (${event.code})`);
Expand Down
Loading