From f9aa2fc374b77fc8325d0c7644ffc9c96169c3c6 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sat, 21 Dec 2024 16:05:04 -0500 Subject: [PATCH] Export LaunchClipClearProcess; use more reliable method to manipulate os.Args for GUI clients --- core/copyUNIXGeneric.go | 2 +- core/launchClipClearProcessCLIGeneric.go | 4 ++-- core/launchClipClearProcessCLIUNIX.go | 4 ++-- core/launchClipClearProcessGUIGeneric.go | 7 ++++--- core/launchClipClearProcessGUIUNIX.go | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/core/copyUNIXGeneric.go b/core/copyUNIXGeneric.go index 60385b2..e9b5979 100644 --- a/core/copyUNIXGeneric.go +++ b/core/copyUNIXGeneric.go @@ -31,7 +31,7 @@ func copyString(continuous bool, copySubject string) { } if !continuous { - launchClipClearProcess(copySubject, isWayland) + LaunchClipClearProcess(copySubject, isWayland) } } diff --git a/core/launchClipClearProcessCLIGeneric.go b/core/launchClipClearProcessCLIGeneric.go index c7b1bff..6deef47 100644 --- a/core/launchClipClearProcessCLIGeneric.go +++ b/core/launchClipClearProcessCLIGeneric.go @@ -8,9 +8,9 @@ import ( "os/exec" ) -// launchClipClearProcess launches the automated clipboard clearing process. +// LaunchClipClearProcess launches the timed clipboard clearing process. // For non-interactive CLI implementations, an entirely separate process is created for this purpose. -func launchClipClearProcess(copySubject string) { +func LaunchClipClearProcess(copySubject string) { executableName := os.Args[0] cmd := exec.Command(executableName, "clipclear") writeToStdin(cmd, copySubject) diff --git a/core/launchClipClearProcessCLIUNIX.go b/core/launchClipClearProcessCLIUNIX.go index 2843da3..d461abf 100644 --- a/core/launchClipClearProcessCLIUNIX.go +++ b/core/launchClipClearProcessCLIUNIX.go @@ -9,9 +9,9 @@ import ( "strconv" ) -// launchClipClearProcess launches the automated clipboard clearing process. +// LaunchClipClearProcess launches the timed clipboard clearing process. // For non-interactive CLI implementations, an entirely separate process is created for this purpose. -func launchClipClearProcess(copySubject string, isWayland bool) { +func LaunchClipClearProcess(copySubject string, isWayland bool) { executableName := os.Args[0] cmd := exec.Command(executableName, "clipclear", strconv.FormatBool(isWayland)) writeToStdin(cmd, copySubject) diff --git a/core/launchClipClearProcessGUIGeneric.go b/core/launchClipClearProcessGUIGeneric.go index c47fa92..97b1377 100644 --- a/core/launchClipClearProcessGUIGeneric.go +++ b/core/launchClipClearProcessGUIGeneric.go @@ -2,8 +2,9 @@ package core -// launchClipClearProcess launches the automated clipboard clearing process. +// LaunchClipClearProcess launches the timed clipboard clearing process. // For interactive GUI/TUI implementations, the clipboard clearing process is launched as a goroutine. -func launchClipClearProcess(copySubject string) { - go clipClearProcess(copySubject) +// copySubject can be omitted to clear the clipboard immediately and unconditionally. +func LaunchClipClearProcess(copySubject string) { + go ClipClearProcess(copySubject) } diff --git a/core/launchClipClearProcessGUIUNIX.go b/core/launchClipClearProcessGUIUNIX.go index b3ea810..7195dc3 100644 --- a/core/launchClipClearProcessGUIUNIX.go +++ b/core/launchClipClearProcessGUIUNIX.go @@ -7,9 +7,10 @@ import ( "strconv" ) -// launchClipClearProcess launches the automated clipboard clearing process. +// LaunchClipClearProcess launches the timed clipboard clearing process. // For interactive GUI/TUI implementations, the clipboard clearing process is launched as a goroutine. -func launchClipClearProcess(copySubject string, isWayland bool) { - os.Args[2] = strconv.FormatBool(isWayland) +// copySubject can be omitted to clear the clipboard immediately and unconditionally. +func LaunchClipClearProcess(copySubject string, isWayland bool) { + os.Args = []string{os.Args[0], "", strconv.FormatBool(isWayland)} go clipClearProcess(copySubject) }