Skip to content

Commit

Permalink
fix(robot): switch package, waiting for clipboard to change after copy
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlindquist committed May 20, 2024
1 parent 353edde commit be8764b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"xterm-addon-web-links": "0.9.0"
},
"dependencies": {
"@hurdlegroup/robotjs": "^0.11.7",
"@jitsi/robotjs": "^0.6.13",
"@johnlindquist/clipboard": "^0.1.38",
"@johnlindquist/kit": "^2.3.1",
"@johnlindquist/mac-clipboard-listener": "^1.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/main/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import log from 'electron-log';
import { kitState } from '../shared/state';

// REMOVE-NUT
import robot from '@hurdlegroup/robotjs';
import robot from '@jitsi/robotjs';
// END-REMOVE-NUT

export const deleteText = async (stringToDelete = '') => {
Expand Down
16 changes: 14 additions & 2 deletions src/main/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import detect from 'detect-port';
import sizeOf from 'image-size';
import untildify from 'untildify';
// REMOVE-NUT
import robot from '@hurdlegroup/robotjs';
import robot from '@jitsi/robotjs';
// END-REMOVE-NUT
// REMOVE-MAC
import nmp from 'node-mac-permissions';
Expand Down Expand Up @@ -97,7 +97,7 @@ import { format, formatDistanceToNowStrict } from 'date-fns';
import { prompts } from './prompts';

const getModifier = () => {
return kitState.isMac ? 'command' : 'control';
return kitState.isMac ? ['command'] : ['control'];
};

export type ChannelHandler = {
Expand Down Expand Up @@ -1657,9 +1657,21 @@ export const createMessageMap = (info: ProcessAndPrompt) => {
// REMOVE-NUT
const modifier = getModifier();
log.info(`COPYING with ${modifier}+c`);
const beforeText = clipboard.readText();
robot.keyTap('c', modifier);

let afterText = clipboard.readText();
const maxTries = 5;
let tries = 0;
while (beforeText === afterText && tries < maxTries) {
afterText = clipboard.readText();
tries++;
log.info(`Retrying copy`, { tries, afterText });
await new Promise((resolve) => setTimeout(resolve, 100));
}

childSend({ channel, value });

// END-REMOVE-NUT
},
),
Expand Down
4 changes: 0 additions & 4 deletions src/renderer/src/hooks/useThemeDetector.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { platform } from 'process';
import { useCallback, useEffect } from 'react';

export default () => {
// set a variable to "isLinux". Don't use "platform" because it's deprecated
const isLinux = platform === 'linux';

const mqListener = useCallback((e: MediaQueryListEvent) => {
// if (isLinux) {
// document.documentElement.style.setProperty('--opacity', '1');
Expand Down

0 comments on commit be8764b

Please sign in to comment.