mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-07 22:04:06 +08:00
fix: 修复了linux上剪贴板监听程序无法正确执行的问题
This commit is contained in:
parent
9c29b5d2b7
commit
f6732f0147
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.
@ -1,5 +1,5 @@
|
||||
{
|
||||
"title": "重要版本更新提示",
|
||||
"content": "1. 如果你是第一次使用此插件, 请务必设置跟随主程序启动选项, 否则可能导致剪贴板记录丢失</br>2. v1.4.0及以上版本 Linux用户需手动安装clipboard-event-handler-linux至usr/bin目录 详见插件官网指南</br>3. 插件使用过程中遇到任何问题, 请到论坛发布页回帖或加入QQ群反馈",
|
||||
"version": 2
|
||||
"content": "1. 如果你是第一次使用此插件, 请务必设置跟随主程序启动选项, 否则可能导致剪贴板记录丢失</br>2. 插件使用过程中遇到任何问题, 请到论坛发布页回帖或加入QQ群反馈",
|
||||
"version": 1
|
||||
}
|
||||
|
@ -212,18 +212,19 @@ export default function initPlugin() {
|
||||
db.addItem(item)
|
||||
})
|
||||
|
||||
const callBack = () => {
|
||||
const info = '请手动安装 clipboard-event-handler-linux 到 /usr/bin'
|
||||
const site =
|
||||
'https://ziuchen.gitee.io/project/ClipboardManager/guide/#如何手动安装clipboard-event-handler-linux'
|
||||
listener
|
||||
.on('close', () => {
|
||||
utools.showNotification('剪贴板监听异常关闭' + (utools.isLinux() ? info : ''))
|
||||
utools.showNotification('剪贴板监听退出' + (utools.isLinux() ? info : ''))
|
||||
utools.isLinux() ? utools.shellOpenExternal(site) : ''
|
||||
utools.outPlugin()
|
||||
})
|
||||
.on('exit', () => {
|
||||
utools.showNotification('剪贴板监听异常退出' + (utools.isLinux() ? info : ''))
|
||||
utools.isLinux() ? utools.shellOpenExternal(site) : ''
|
||||
}
|
||||
listener
|
||||
.on('close', callBack())
|
||||
.on('exit', callBack())
|
||||
.on('error', (error) => {
|
||||
utools.showNotification('剪贴板监听出错' + error)
|
||||
utools.outPlugin()
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user