feat: increase clipboard history limit to 1000 items

This commit is contained in:
Menno van Leeuwen 2025-05-21 00:15:33 +02:00
parent b2d9167b95
commit 380742a869
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
3 changed files with 3 additions and 18 deletions

View File

@ -14,4 +14,4 @@ logging:
clipboard:
# Maximum number of items to keep in the clipboard history.
max_items: 100
max_items: 1000

View File

@ -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")
}
}
},
}

View File

@ -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()