mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-09-27 05:43:21 +08:00
fix: 修复了linux上剪贴板监听程序无法正确执行的问题
This commit is contained in:
24
public/node_modules/clipboard-event/index.js
generated
vendored
24
public/node_modules/clipboard-event/index.js
generated
vendored
@@ -1,6 +1,8 @@
|
||||
const { chmodSync, existsSync, mkdirSync, copyFileSync } = require('fs')
|
||||
const { EventEmitter } = require('events');
|
||||
const path = require('path');
|
||||
const { execFile, exec } = require('child_process');
|
||||
const { execFile } = require('child_process');
|
||||
const homeDir = require('os').homedir();
|
||||
|
||||
class ClipboardEventListener extends EventEmitter {
|
||||
constructor() {
|
||||
@@ -13,8 +15,16 @@ class ClipboardEventListener extends EventEmitter {
|
||||
this.child = execFile(path.join(__dirname, 'platform/clipboard-event-handler-mac'));
|
||||
}
|
||||
else if (platform === 'linux') {
|
||||
// manually install clipboard-event-handler-linux to /usr/local/bin
|
||||
this.child = exec('clipboard-event-handler-linux')
|
||||
// linux: cant execFile without chmod, and cant chmod in app.asar
|
||||
// so we need to copy the file to /usr/bin
|
||||
const target = path.resolve(homeDir, '.local', 'bin')
|
||||
const p = path.join(__dirname, 'platform/clipboard-event-handler-linux')
|
||||
if(!existsSync(target)) {
|
||||
mkdirSync(target)
|
||||
}
|
||||
copyFileSync(p, path.join(target, 'clipboard-event-handler-linux'))
|
||||
chmodSync(path.join(target, 'clipboard-event-handler-linux'), 0o755)
|
||||
this.child = execFile(path.join(target, 'clipboard-event-handler-linux'));
|
||||
}
|
||||
else if (platform === 'darwin') {
|
||||
this.child = execFile(path.join(__dirname, 'platform/clipboard-event-handler-mac'));
|
||||
@@ -27,11 +37,11 @@ class ClipboardEventListener extends EventEmitter {
|
||||
this.emit('change');
|
||||
}
|
||||
});
|
||||
this.child.stdout.on('close', (code) => {
|
||||
this.emit('close', code);
|
||||
this.child.stdout.on('close', () => {
|
||||
this.emit('close');
|
||||
});
|
||||
this.child.stdout.on('exit', (code) => {
|
||||
this.emit('exit', code);
|
||||
this.child.stdout.on('exit', () => {
|
||||
this.emit('exit');
|
||||
});
|
||||
}
|
||||
stopListening() {
|
||||
|
BIN
public/node_modules/clipboard-event/platform/clipboard-event-handler-linux
generated
vendored
Normal file
BIN
public/node_modules/clipboard-event/platform/clipboard-event-handler-linux
generated
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user