wilix-team / iohook

Node.js global keyboard and mouse listener.
https://wilix-team.github.io/iohook
MIT License
1.18k stars 290 forks source link

is anybody manage to make it work on linux? #397

Open hiwyn opened 2 years ago

hiwyn commented 2 years ago

Looks like it is not working plug and play on linux, is anybody manage to install it and detect key pressed on linux? How?

manpreet981 commented 2 years ago

I tried but it's not working as expected.

hiwyn commented 2 years ago

i cant even run a simple script like:

const ioHook = require("iohook");

ioHook.on("keypress", (event) => {
  console.log(event);
  if (event.keychar == "a") {
    console.log("wow! A pressed!");
  }
  // {keychar: 'f', keycode: 19, rawcode: 15, type: 'keypress'}
});
ioHook.start();
manpreet981 commented 2 years ago

@hiwyn are you able to fix this error?

Error: GET https://github.com/wilix-team/iohook/releases/download/v0.9.3/iohook-v0.9.3-electron-v87-linux-ia32.tar.gz returned 404 Prebuild for current platform (iohook-v0.9.3-electron-v87-linux-ia32) not found!

marcelblum commented 2 years ago

@manpreet981 iohook ended support for 32 bit Linux so there is no prebuild for that platform. You can try compiling manually or use an older version of iohook.

jove0610 commented 2 years ago

@hiwyn can you give more info? I can run in it Linux (Ubuntu) no problem. I did the manual build approach though so that I can use electron 18 (latest) and node 16.

manpreet981 commented 2 years ago

@marcelblum thanks, I will check that.

@jove0610 are you able to manage it with pipeline also?

jove0610 commented 2 years ago

@manpreet981 I just do npm ci, then download the build I created in google drive and paste it in the iohook modules.

hiwyn commented 2 years ago

@jove0610 same problem then here https://github.com/wilix-team/iohook/issues/386

could you tell me the steps u follow to rebuild it? because i did the npm rebuild but still showing the same error:

hiwyn@hiwyn:~/tendonitis$ npm rebuild
rebuilt dependencies successfully
hiwyn@hiwyn:~/tendonitis$ node index.js
load_input_helper [1918]: Using XFree86 keyboard layout.
load_input_helper [1920]: XKB support is required to accurately determine keyboard characters!
internal/modules/cjs/loader.js:1057
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '/home/hiwyn/tendonitis/node_modules/iohook/builds/node-v72-linux-x64/build/Release/iohook.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 87. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/hiwyn/tendonitis/node_modules/iohook/index.js:24:21)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
hiwyn@hiwyn:~/tendonitis$ 
dement6d commented 2 years ago

could you tell me the steps u follow to rebuild it? because i did the npm rebuild but still showing the same error:

Clone the repository with git clone https://github.com/wilix-team/iohook If you're on windows, make sure you have Visual Studio Node.js Build Tools installed. Then, install the required dependencies for the iohook project with npm install and then build iohook with npm run build. If built successfully, you will have a builds folder with iohook built for the node version you were using.

I think this should theoretically work but i am facing an issue where the version i built doesn't work as "iohook.node is not a valid Win32 application" according to the error i get when i try to run my app which includes iohook

lacymorrow commented 8 months ago

Duplicate #348