1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-09 15:22:13 -04:00

clipboard: add watch -m for mime-types

This commit is contained in:
bbedward
2026-02-04 11:36:41 -05:00
parent bd9029e533
commit fe15667986
2 changed files with 154 additions and 2 deletions

View File

@@ -112,6 +112,7 @@ var clipClearCmd = &cobra.Command{
}
var clipWatchStore bool
var clipWatchMimes bool
var clipSearchCmd = &cobra.Command{
Use: "search [query]",
@@ -211,6 +212,7 @@ func init() {
clipConfigSetCmd.Flags().BoolVar(&clipConfigEnabled, "enable", false, "Enable clipboard tracking")
clipWatchCmd.Flags().BoolVarP(&clipWatchStore, "store", "s", false, "Store clipboard changes to history (no server required)")
clipWatchCmd.Flags().BoolVarP(&clipWatchMimes, "mimes", "m", false, "Show all offered MIME types")
clipMigrateCmd.Flags().BoolVar(&clipMigrateDelete, "delete", false, "Delete cliphist db after successful migration")
@@ -328,6 +330,30 @@ func runClipWatch(cmd *cobra.Command, args []string) {
}); err != nil && err != context.Canceled {
log.Fatalf("Watch error: %v", err)
}
case clipWatchMimes:
if err := clipboard.WatchAll(ctx, func(data []byte, mimeType string, allMimes []string) {
if clipJSONOutput {
out := map[string]any{
"data": string(data),
"mimeType": mimeType,
"mimeTypes": allMimes,
"timestamp": time.Now().Format(time.RFC3339),
"size": len(data),
}
j, _ := json.Marshal(out)
fmt.Println(string(j))
return
}
fmt.Printf("=== Clipboard Change ===\n")
fmt.Printf("Selected: %s\n", mimeType)
fmt.Printf("All MIME types:\n")
for _, m := range allMimes {
fmt.Printf(" - %s\n", m)
}
fmt.Printf("Size: %d bytes\n\n", len(data))
}); err != nil && err != context.Canceled {
log.Fatalf("Watch error: %v", err)
}
case clipJSONOutput:
if err := clipboard.Watch(ctx, func(data []byte, mimeType string) {
out := map[string]any{