From 3fdcc9e96d71bb4bef3baf9f43a627782237b142 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 30 Jun 2025 22:46:17 -0400 Subject: [PATCH] Allow one-time copy of TOTP codes --- core/copy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/copy.go b/core/copy.go index da1b963..d652951 100644 --- a/core/copy.go +++ b/core/copy.go @@ -14,6 +14,7 @@ import ( ) // CopyArgument copies a field from an entry to the clipboard. +// If field is -1, it will not continuously update the clipboard (one-time copy). func CopyArgument(targetLocation string, field int) error { // ensure targetLocation exists and is a file _, err := back.TargetIsFile(targetLocation, true) @@ -35,7 +36,7 @@ func CopyArgument(targetLocation string, field int) error { return errors.New("field is empty") } - if field != 2 { + if field != 2 && field != -1 { copySubject = decryptedEntry[field] } else { // TOTP mode var secret string // stores secret for TOTP generation @@ -60,6 +61,9 @@ func CopyArgument(targetLocation string, field int) error { if err != nil { return err } + if field == -1 { + return nil // return early (for interactive clients) + } // sleep until next 30-second interval time.Sleep(time.Duration(30-(currentTime.Second()%30)) * time.Second) }