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: clipboard:
# Maximum number of items to keep in the clipboard history. # 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") log.Fatal().Err(err).Msg("Failed to initialize clipboard")
} }
var ( var lastText string
lastText string
lastImage []byte
)
for { for {
time.Sleep(250 * time.Millisecond) time.Sleep(250 * time.Millisecond)
textOut := clipboard.Read(clipboard.FmtText) textOut := clipboard.Read(clipboard.FmtText)
imgOut := clipboard.Read(clipboard.FmtImage)
if len(textOut) > 0 { if len(textOut) > 0 {
text := string(textOut) text := string(textOut)
@ -102,18 +98,6 @@ func NewWatchCmd(history *models.History) *cobra.Command {
log.Info().Str("content", text).Msg("Text item added ") 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() file.Close()
} }
cfg.Clipboard.MaxItems = 1000
cfg.Logging.Format = "console" cfg.Logging.Format = "console"
cfg.Logging.Level = "info" cfg.Logging.Level = "info"
cfg.Logging.Path = logFilePath() cfg.Logging.Path = logFilePath()