Open7

Electron

oktntkooktntko

環境
WSL2
Debian
Node
PNPM

Electron QuickStart
https://www.electronjs.org/docs/latest/tutorial/quick-start#scaffold-the-project

pnpm start したら失敗

pnpm start

> ring-command@1.0.0 start /home/oktntko/workspace/ring-command
> electron .

/home/oktntko/workspace/ring-command/node_modules/.pnpm/electron@28.2.1/node_modules/electron/dist/electron: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory
 ELIFECYCLE  Command failed.
oktntkooktntko

libgobject-2.0.so.0
❯ sudo apt install -y libglib2.0-dev

libdbus-1.so.3
❯ sudo apt install -y libdbus-glib-1-dev

libatk-1.0.so.0
❯ sudo apt install -y libatk1.0-dev

libatk-bridge-2.0.so.0
❯ sudo apt install -y libatk-bridge2.0-dev

libcups.so.2
❯ sudo apt install -y libcups2-dev

libdrm.so.2
❯ sudo apt install -y libdrm-dev

libgtk-3.so.0
❯ sudo apt install -y libgtk-3-dev

libasound.so.2
❯ sudo apt install -y libasound2-dev

ようやく

pnpm start

> ring-command@1.0.0 start /home/oktntko/workspace/ring-command
> electron .

[57122:0206/234603.291581:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Error launching app
Unable to find Electron app at /home/oktntko/workspace/ring-command

Cannot find module '/home/oktntko/workspace/ring-command/index.js'. Please verify that the package.json has a valid "main" entry
 ELIFECYCLE  Command failed with exit code 1.
oktntkooktntko

コピーすると動く

https://github.com/electron/electron-quick-start/tree/main

  • index.html
  • main.js
  • package.json
  • preload.js
  • renderer.js
  • styles.css

動くがエラーメッセージが表示される

[59222:0206/235152.004629:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[59222:0206/235152.006332:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
oktntkooktntko

build:unpack 成功
build:win 失敗
build:mac 失敗
build:linux 成功

build:win に失敗してもdistフォルダにできたwin-unpackedを使えばWindows上の動作確認はできる。

oktntkooktntko

globalShortcut ではショートカットしか捕捉できない。
'CommandOrControl+X' はいいけど 'X' や 'CommandOrControl' はとれない。