From 380742a86940615d09ab844215acfcb070fa9e58 Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Wed, 21 May 2025 00:15:33 +0200 Subject: [PATCH] feat: increase clipboard history limit to 1000 items --- config.yml | 2 +- src/commands/cmd_watch.go | 18 +----------------- src/config/config.go | 1 + 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/config.yml b/config.yml index 66bddea..c93914a 100644 --- a/config.yml +++ b/config.yml @@ -14,4 +14,4 @@ logging: clipboard: # Maximum number of items to keep in the clipboard history. - max_items: 100 + max_items: 1000 diff --git a/src/commands/cmd_watch.go b/src/commands/cmd_watch.go index 7c78587..d65c781 100644 --- a/src/commands/cmd_watch.go +++ b/src/commands/cmd_watch.go @@ -77,16 +77,12 @@ func NewWatchCmd(history *models.History) *cobra.Command { log.Fatal().Err(err).Msg("Failed to initialize clipboard") } - var ( - lastText string - lastImage []byte - ) + var lastText string for { time.Sleep(250 * time.Millisecond) textOut := clipboard.Read(clipboard.FmtText) - imgOut := clipboard.Read(clipboard.FmtImage) if len(textOut) > 0 { text := string(textOut) @@ -102,18 +98,6 @@ func NewWatchCmd(history *models.History) *cobra.Command { log.Info().Str("content", text).Msg("Text item added ") } } - - if len(imgOut) > 0 && (lastImage == nil || string(imgOut) != string(lastImage)) { - item := models.HistoryItem{ - Data: imgOut, - DataType: 1, // 1 for image/png - Timestamp: time.Now(), - Pinned: false, - } - history.Add(item) - lastImage = imgOut - log.Info().Msg("Image item added") - } } }, } diff --git a/src/config/config.go b/src/config/config.go index fdffd90..08370e6 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -48,6 +48,7 @@ func LoadConfig() (Config, string) { file.Close() } + cfg.Clipboard.MaxItems = 1000 cfg.Logging.Format = "console" cfg.Logging.Level = "info" cfg.Logging.Path = logFilePath()