go-passbolt-cli/util/clipboard.go
2023-02-19 00:23:16 +01:00

27 lines
635 B
Go

package util
import (
"fmt"
"time"
"golang.design/x/clipboard"
)
var delaySeconds int = 5
// SetDelay Set the delay between entries
func SetDelay(delay int) {
delaySeconds = delay
}
/*
CopyValueToClipboard Copy the given value to clipboard and sleeps for seconds defined with SetDelay (default: 5 seconds).
After the delay the clipboard will be emptied
*/
func CopyValueToClipboard(entryName string, value string) {
clipboard.Write(clipboard.FmtText, []byte(value))
fmt.Printf("Copying %s to clipboard...\n", entryName)
time.Sleep(time.Duration(delaySeconds) * time.Second)
clipboard.Write(clipboard.FmtText, []byte{})
}