diff --git a/tailscalectl/TailscaleWidget.qml b/tailscalectl/TailscaleWidget.qml index da6b6ca..aec7a31 100644 --- a/tailscalectl/TailscaleWidget.qml +++ b/tailscalectl/TailscaleWidget.qml @@ -13,6 +13,7 @@ PluginComponent { property string tailscaleIP: "" property string currentExitNode: "" property var peers: [] + property string clipboardCmd: "" layerNamespacePlugin: "tailscalectl" popoutWidth: 360 @@ -25,7 +26,9 @@ PluginComponent { onTriggered: statusCheck.running = true } - Component.onCompleted: statusCheck.running = true + Component.onCompleted: { + detectClipboard.running = true + } Process { id: toggleProcess @@ -39,6 +42,22 @@ PluginComponent { 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 { id: statusCheck @@ -89,7 +108,11 @@ PluginComponent { } 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 ToastService.showInfo("tailscalectl", "Copied: " + text) }