feat: auto-detect clipboard tool at startup (#6)\n\n- Priority: dms cl copy → wl-copy → clipmanctl copy → none\n- Show error toast if no clipboard tool is found\n- statusCheck runs after clipboard detection completes

This commit is contained in:
Vybe (Coding Agent) 2026-05-18 05:08:15 +00:00
parent 2c29fcc0b6
commit d8bd3c6c30

View file

@ -13,6 +13,7 @@ PluginComponent {
property string tailscaleIP: "" property string tailscaleIP: ""
property string currentExitNode: "" property string currentExitNode: ""
property var peers: [] property var peers: []
property string clipboardCmd: ""
layerNamespacePlugin: "tailscalectl" layerNamespacePlugin: "tailscalectl"
popoutWidth: 360 popoutWidth: 360
@ -25,7 +26,9 @@ PluginComponent {
onTriggered: statusCheck.running = true onTriggered: statusCheck.running = true
} }
Component.onCompleted: statusCheck.running = true Component.onCompleted: {
detectClipboard.running = true
}
Process { Process {
id: toggleProcess id: toggleProcess
@ -39,6 +42,22 @@ PluginComponent {
id: copyProcess id: copyProcess
} }
Process {
id: detectClipboard
command: ["sh", "-c", "which dms >/dev/null 2>&1 && echo 'dms cl copy' || which wl-copy >/dev/null 2>&1 && echo 'wl-copy' || which clipmanctl >/dev/null 2>&1 && echo 'clipmanctl copy' || echo none"]
stdout: StdioCollector {
onStreamFinished: {
root.clipboardCmd = this.text.trim()
}
}
onExited: (code, status) => {
statusCheck.running = true
}
}
Process { Process {
id: statusCheck id: statusCheck
@ -89,7 +108,11 @@ PluginComponent {
} }
function copyToClipboard(text) { function copyToClipboard(text) {
copyProcess.command = ["sh", "-c", "printf '%s' '" + text.replace(/'/g, "'\\''") + "' | wl-copy"] if (!root.clipboardCmd || root.clipboardCmd === "none") {
ToastService.showError("tailscalectl", "No clipboard tool found")
return
}
copyProcess.command = ["sh", "-c", "printf '%s' '" + text.replace(/'/g, "'\\''") + "' | " + root.clipboardCmd]
copyProcess.running = true copyProcess.running = true
ToastService.showInfo("tailscalectl", "Copied: " + text) ToastService.showInfo("tailscalectl", "Copied: " + text)
} }