diff --git a/clip/clipClearProcess_DROID.go b/clip/clipClearProcess_DROID.go deleted file mode 100644 index 85e0461..0000000 --- a/clip/clipClearProcess_DROID.go +++ /dev/null @@ -1,36 +0,0 @@ -//go:build (android && !termux) || ios - -package clip - -import ( - "strings" - "time" - - "github.com/rwinkhart/go-boilerplate/back" - "golang.design/x/clipboard" -) - -// ClipClearProcess clears the clipboard after 30 seconds if the clipboard contents have not changed. -// assignedContents can be omitted to clear the clipboard immediately and unconditionally. -func ClipClearProcess(assignedContents string) error { - clearClipboard := func() { - clipboard.Write(clipboard.FmtText, []byte("")) - back.Exit(0) - } - - // if assignedContents is empty, clear the clipboard immediately and unconditionally - if assignedContents == "" { - clearClipboard() - return nil - } - - // wait 30 seconds before checking clipboard contents - time.Sleep(30 * time.Second) - - newContents := clipboard.Read(clipboard.FmtText) - - if assignedContents == strings.TrimRight(string(newContents), "\r\n") { - clearClipboard() - } - return nil -} diff --git a/clip/copy_DARWIN.go b/clip/copy_MAC.go similarity index 85% rename from clip/copy_DARWIN.go rename to clip/copy_MAC.go index 057908f..5d7d18a 100644 --- a/clip/copy_DARWIN.go +++ b/clip/copy_MAC.go @@ -10,14 +10,14 @@ import ( ) // CopyString copies a string to the clipboard. -func CopyString(continuous bool, copySubject string) error { +func CopyString(clearClipboardAutomatically bool, copySubject string) error { cmd := exec.Command("pbcopy") _ = back.WriteToStdin(cmd, copySubject) err := cmd.Run() if err != nil { return errors.New("unable to copy to clipboard: " + err.Error()) } - if !continuous { + if clearClipboardAutomatically { LaunchClipClearProcess(copySubject) } return nil diff --git a/clip/copy_MOBILE.go b/clip/copy_MOBILE.go deleted file mode 100644 index bd5c161..0000000 --- a/clip/copy_MOBILE.go +++ /dev/null @@ -1,16 +0,0 @@ -//go:build (android && !termux) || ios - -package clip - -import ( - "golang.design/x/clipboard" -) - -// CopyString copies a string to the clipboard. -func CopyString(continuous bool, copySubject string) error { - clipboard.Write(clipboard.FmtText, []byte(copySubject)) - if !continuous { - LaunchClipClearProcess(copySubject) - } - return nil -} diff --git a/clip/copy_TERMUX.go b/clip/copy_TERMUX.go index 5f251ea..c54c217 100644 --- a/clip/copy_TERMUX.go +++ b/clip/copy_TERMUX.go @@ -10,14 +10,14 @@ import ( ) // CopyString copies a string to the clipboard. -func CopyString(continuous bool, copySubject string) error { +func CopyString(clearClipboardAutomatically bool, copySubject string) error { cmd := exec.Command("termux-clipboard-set") _ = back.WriteToStdin(cmd, copySubject) err := cmd.Run() if err != nil { return errors.New("unable to copy to clipboard: " + err.Error()) } - if !continuous { + if clearClipboardAutomatically { LaunchClipClearProcess(copySubject) } return nil diff --git a/clip/copy_UNIX.go b/clip/copy_UNIX.go index 2293b50..b012abf 100644 --- a/clip/copy_UNIX.go +++ b/clip/copy_UNIX.go @@ -11,7 +11,7 @@ import ( ) // CopyString copies a string to the clipboard. -func CopyString(continuous bool, copySubject string) error { +func CopyString(clearClipboardAutomatically bool, copySubject string) error { // determine whether to use wl-copy (Wayland) or xclip (X11) var envSet, isWayland bool // track whether environment variables are set var cmdCopy *exec.Cmd @@ -29,7 +29,7 @@ func CopyString(continuous bool, copySubject string) error { if err != nil { return errors.New("unable to copy to clipboard: " + err.Error()) } - if !continuous { + if clearClipboardAutomatically { LaunchClipClearProcess(copySubject, isWayland) } return nil diff --git a/clip/copy_WIN.go b/clip/copy_WIN.go index 399212c..6bdbeb7 100644 --- a/clip/copy_WIN.go +++ b/clip/copy_WIN.go @@ -10,13 +10,13 @@ import ( ) // CopyString copies a string to the clipboard. -func CopyString(continuous bool, copySubject string) error { +func CopyString(clearClipboardAutomatically bool, copySubject string) error { cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", strings.ReplaceAll(copySubject, "'", "''"))) err := cmd.Run() if err != nil { return errors.New("unable to copy to clipboard: " + err.Error()) } - if !continuous { + if clearClipboardAutomatically { LaunchClipClearProcess(copySubject) } return nil diff --git a/clip/launchClipClearProcessCLI_GENERIC.go b/clip/launchClipClearProcessCLI_GENERIC.go index 0897093..aa6b312 100644 --- a/clip/launchClipClearProcessCLI_GENERIC.go +++ b/clip/launchClipClearProcessCLI_GENERIC.go @@ -1,4 +1,4 @@ -//go:build (windows || darwin || android || ios || termux || wsl) && !interactive +//go:build (windows || wsl || (darwin && !ios) || (android && termux)) && !interactive package clip diff --git a/clip/launchClipClearProcessGUI_GENERIC.go b/clip/launchClipClearProcessGUI_GENERIC.go index 2c26ef3..b802e43 100644 --- a/clip/launchClipClearProcessGUI_GENERIC.go +++ b/clip/launchClipClearProcessGUI_GENERIC.go @@ -1,4 +1,4 @@ -//go:build (windows || darwin || android || ios || termux || wsl) && interactive +//go:build (windows || wsl || (darwin && !ios) || (android && termux)) && interactive package clip diff --git a/go.mod b/go.mod index 521e523..45c06c4 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/pquerna/otp v1.5.0 github.com/rwinkhart/go-boilerplate v0.1.1-0.20251110055016-10ee4f91fcb6 github.com/rwinkhart/rcw v0.2.3 - golang.design/x/clipboard v0.7.1 // only for mobile builds golang.org/x/crypto v0.43.0 gopkg.in/ini.v1 v1.67.0 ) @@ -17,9 +16,6 @@ require ( github.com/boombuler/barcode v1.1.0 // indirect github.com/kr/fs v0.1.0 // indirect github.com/rwinkhart/peercred-mini v0.1.2 // indirect - golang.org/x/exp/shiny v0.0.0-20251017212417-90e834f514db // indirect; only for mobile builds - golang.org/x/image v0.32.0 // indirect; only for mobile builds - golang.org/x/mobile v0.0.0-20251021151156-188f512ec823 // indirect; only for mobile builds golang.org/x/sys v0.38.0 // indirect ) diff --git a/go.sum b/go.sum index b3cc29a..c1b193d 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pquerna/otp v1.5.0 h1:NMMR+WrmaqXU4EzdGJEE1aUUI0AMRzsp96fFFWNPwxs= github.com/pquerna/otp v1.5.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg= -github.com/rwinkhart/go-boilerplate v0.1.0 h1:EzlVj6R7Bxtl79Nl7R5zRcg6s+Cf2FAqGIzR4giWTQg= -github.com/rwinkhart/go-boilerplate v0.1.0/go.mod h1:cnzIF45I0FCOvE4YIB+26pLCUx2kWyY2llKYZruNaRY= github.com/rwinkhart/go-boilerplate v0.1.1-0.20251110055016-10ee4f91fcb6 h1:tGGtw5Wr4laDrU7Ooe95g4E+O6c+oY18atamcMPaMY8= github.com/rwinkhart/go-boilerplate v0.1.1-0.20251110055016-10ee4f91fcb6/go.mod h1:cnzIF45I0FCOvE4YIB+26pLCUx2kWyY2llKYZruNaRY= github.com/rwinkhart/go-winio v0.1.0 h1:b72agLW+dETGmhR3VbcbwnStfgKfc5AfgJOXBJDkaHg= @@ -28,16 +26,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.design/x/clipboard v0.7.1 h1:OEG3CmcYRBNnRwpDp7+uWLiZi3hrMRJpE9JkkkYtz2c= -golang.design/x/clipboard v0.7.1/go.mod h1:i5SiIqj0wLFw9P/1D7vfILFK0KHMk7ydE72HRrUIgkg= golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= -golang.org/x/exp/shiny v0.0.0-20251017212417-90e834f514db h1:NmsmaSkEAq6A8r0Q78WxD0IygJNCs6J3uYDgNuPkXYM= -golang.org/x/exp/shiny v0.0.0-20251017212417-90e834f514db/go.mod h1:QMAAUorQ8fzCK0C6mr4X4XV9BEp7Al6+jlejJvfYKw4= -golang.org/x/image v0.32.0 h1:6lZQWq75h7L5IWNk0r+SCpUJ6tUVd3v4ZHnbRKLkUDQ= -golang.org/x/image v0.32.0/go.mod h1:/R37rrQmKXtO6tYXAjtDLwQgFLHmhW+V6ayXlxzP2Pc= -golang.org/x/mobile v0.0.0-20251021151156-188f512ec823 h1:M0DtBf/UvJoTH+tk6tgHT2NVxNEJCYhVu1g/xeD+GEk= -golang.org/x/mobile v0.0.0-20251021151156-188f512ec823/go.mod h1:3QSlP0AtP6HPTLbsxfgfefGN76jpIB9yBsMqB8UY37I= golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q= golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= diff --git a/wiki/developers.md b/wiki/developers.md index cd6de3a..177fac5 100644 --- a/wiki/developers.md +++ b/wiki/developers.md @@ -20,6 +20,9 @@ These are as follows: - `clipclear`: Should be accepted by all non-interactive CLI libmutton implementations (not required for interactive GUI/TUI implementations). In order to clear the clipboard on a timer, non-interactive libmutton-based password managers call another instance of their executable with the `clipclear` argument (e.g. `mutn clipclear`) with the intended clipboard contents provided via STDIN. If after 30 seconds the clipboard contents have not changed, they are cleared. Please accept a `clipclear` argument that calls `clip.ClipClearArgument()`. - `startrcwd`: Should be accepted by all libmutton implementations making use of the RCW daemon to cache passwords. Please accept a `startrcwd` argument that calls `crypt.RCWDArgument()`. +## Mobile Clipboard Management +In an effort to reduce dependencies not needed in most environments, libmutton no longer provides clipboard management for mobile platforms. This should be handled by your GUI toolkit/framework. + ## Configuration libmutton-based password manager clients should all share the same INI configuration file.