From f5d52f1506d9ff11f5047aeefb23003330a2d2d2 Mon Sep 17 00:00:00 2001 From: purian23 Date: Sun, 14 Jun 2026 23:35:22 -0400 Subject: [PATCH] update(ipc): docs & dms ipc list --- core/cmd/dms/commands_colorpicker.go | 10 +++- core/cmd/dms/commands_common.go | 19 ++++++-- core/cmd/dms/shell.go | 71 +++++++++++++++++----------- docs/IPC.md | 22 ++++++++- quickshell/Common/KeybindActions.js | 3 ++ 5 files changed, 93 insertions(+), 32 deletions(-) diff --git a/core/cmd/dms/commands_colorpicker.go b/core/cmd/dms/commands_colorpicker.go index 7c366e8e..36ed9d74 100644 --- a/core/cmd/dms/commands_colorpicker.go +++ b/core/cmd/dms/commands_colorpicker.go @@ -19,7 +19,12 @@ var ( var colorCmd = &cobra.Command{ Use: "color", Short: "Color utilities", - Long: "Color utilities including picking colors from the screen", + Long: `Color utilities including picking colors from the screen. + +This is the screen eyedropper CLI. To open the in-shell color modal, use: + dms ipc call color-picker toggle + +See: https://danklinux.com/docs/dankmaterialshell/keybinds-ipc`, } var colorPickCmd = &cobra.Command{ @@ -29,6 +34,9 @@ var colorPickCmd = &cobra.Command{ Click on any pixel to capture its color, or press Escape to cancel. +This is the screen eyedropper CLI. To open the in-shell color modal, use: + dms ipc call color-picker toggle + Output format flags (mutually exclusive, default: --hex): --hex - Hexadecimal (#RRGGBB) --rgb - RGB values (R G B) diff --git a/core/cmd/dms/commands_common.go b/core/cmd/dms/commands_common.go index 9a9714d0..27f7931d 100644 --- a/core/cmd/dms/commands_common.go +++ b/core/cmd/dms/commands_common.go @@ -77,10 +77,15 @@ var killCmd = &cobra.Command{ } var ipcCmd = &cobra.Command{ - Use: "ipc [target] [function] [args...]", + Use: "ipc", Short: "Send IPC commands to running DMS shell", + Long: `Send IPC commands to the running DMS shell. + + dms ipc call [args...] invoke a command + dms ipc list list all targets and functions + +Full reference: https://danklinux.com/docs/dankmaterialshell/keybinds-ipc`, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - _ = findConfig(cmd, args) return getShellIPCCompletions(args, toComplete), cobra.ShellCompDirectiveNoFileComp }, Run: func(cmd *cobra.Command, args []string) { @@ -88,9 +93,17 @@ var ipcCmd = &cobra.Command{ }, } +var ipcListCmd = &cobra.Command{ + Use: "list", + Short: "List all IPC targets and functions", + Run: func(cmd *cobra.Command, args []string) { + printIPCHelp() + }, +} + func init() { + ipcCmd.AddCommand(ipcListCmd) ipcCmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { - _ = findConfig(cmd, args) printIPCHelp() }) } diff --git a/core/cmd/dms/shell.go b/core/cmd/dms/shell.go index ced65dcf..4638603c 100644 --- a/core/cmd/dms/shell.go +++ b/core/cmd/dms/shell.go @@ -601,12 +601,30 @@ func parseTargetsFromIPCShowOutput(output string) ipcTargets { return targets } -func getShellIPCCompletions(args []string, _ string) []string { +func buildQsIPCBaseArgs() ([]string, error) { cmdArgs := []string{"ipc"} - if qsHasAnyDisplay() { - cmdArgs = append(cmdArgs, "--any-display") + switch pid, ok := getFirstDMSPID(); { + case ok: + cmdArgs = append(cmdArgs, "--pid", strconv.Itoa(pid)) + default: + if err := findConfig(nil, nil); err != nil { + return nil, err + } + if qsHasAnyDisplay() { + cmdArgs = append(cmdArgs, "--any-display") + } + cmdArgs = append(cmdArgs, "-p", configPath) } - cmdArgs = append(cmdArgs, "-p", configPath, "show") + return cmdArgs, nil +} + +func getShellIPCCompletions(args []string, _ string) []string { + baseArgs, err := buildQsIPCBaseArgs() + if err != nil { + log.Debugf("Error building IPC args for completions: %v", err) + return nil + } + cmdArgs := append(baseArgs, "show") cmd := exec.Command("qs", cmdArgs...) var targets ipcTargets @@ -623,7 +641,7 @@ func getShellIPCCompletions(args []string, _ string) []string { if len(args) == 0 { targetNames := make([]string, 0) - targetNames = append(targetNames, "call") + targetNames = append(targetNames, "call", "list") for k := range targets { targetNames = append(targetNames, k) } @@ -696,23 +714,11 @@ func runShellIPCCommand(args []string) { args = append([]string{"call"}, args...) } - cmdArgs := []string{"ipc"} - - switch pid, ok := getFirstDMSPID(); { - case ok: - cmdArgs = append(cmdArgs, "--pid", strconv.Itoa(pid)) - default: - if err := findConfig(nil, nil); err != nil { - log.Fatalf("Error finding config: %v", err) - } - // ! TODO - remove check when QS 0.3 is released - if qsHasAnyDisplay() { - cmdArgs = append(cmdArgs, "--any-display") - } - cmdArgs = append(cmdArgs, "-p", configPath) + baseArgs, err := buildQsIPCBaseArgs() + if err != nil { + log.Fatalf("Error finding config: %v", err) } - - cmdArgs = append(cmdArgs, args...) + cmdArgs := append(baseArgs, args...) cmd := exec.Command("qs", cmdArgs...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout @@ -724,19 +730,20 @@ func runShellIPCCommand(args []string) { } func printIPCHelp() { - fmt.Println("Usage: dms ipc [args...]") + fmt.Println("Usage: dms ipc call [args...]") fmt.Println() - cmdArgs := []string{"ipc"} - if qsHasAnyDisplay() { - cmdArgs = append(cmdArgs, "--any-display") + baseArgs, err := buildQsIPCBaseArgs() + if err != nil { + printIPCHelpFailure(err) + return } - cmdArgs = append(cmdArgs, "-p", configPath, "show") + cmdArgs := append(baseArgs, "show") cmd := exec.Command("qs", cmdArgs...) output, err := cmd.Output() if err != nil { - fmt.Println("Could not retrieve available IPC targets (is DMS running?)") + printIPCHelpFailure(err) return } @@ -765,6 +772,16 @@ func printIPCHelp() { } } +func printIPCHelpFailure(err error) { + fmt.Println("Could not retrieve IPC targets.") + if err != nil { + fmt.Printf(" %v\n", err) + } + fmt.Println() + fmt.Println(" Full docs: https://danklinux.com/docs/dankmaterialshell/keybinds-ipc") + fmt.Println(" Try: dms ipc call ") +} + // ensureFontCache rebuilds the fontconfig cache if user-configured fonts are missing while skipping defaults func ensureFontCache() { if _, err := exec.LookPath("fc-list"); err != nil { diff --git a/docs/IPC.md b/docs/IPC.md index 88d37e91..b458e7ee 100644 --- a/docs/IPC.md +++ b/docs/IPC.md @@ -6,6 +6,18 @@ DankMaterialShell provides comprehensive IPC (Inter-Process Communication) funct dms ipc call [parameters...] ``` +## Discovering IPC commands + +List all available targets and functions while DMS is running: + +```bash +dms ipc list +dms ipc # same +dms ipc --help # same, plus usage text +``` + +Live listing requires DMS to be running. If listing fails, use this document or the [Keybinds & IPC docs](https://danklinux.com/docs/dankmaterialshell/keybinds-ipc) as an offline reference. + ## Target: `audio` Audio system control and information. @@ -707,7 +719,7 @@ File browser controls for selecting wallpapers and profile images. - Both browsers support common image formats (jpg, jpeg, png, bmp, gif, webp) ### Target: `color-picker` -Color picker modal control. +In-shell color picker modal for theme and settings color selection. **Functions:** - `open` - Show color picker modal @@ -718,6 +730,14 @@ Color picker modal control. - `toggle` - Toggle color picker modal visibility - `toggleInstant` - Toggle color picker modal visibility without animation on hide +**Note:** This controls the in-shell modal. To pick a pixel from the screen via CLI, use `dms color pick` instead (see [Color Picker CLI](https://danklinux.com/docs/dankmaterialshell/cli-color-picker)). + +**Examples:** +```bash +dms ipc call color-picker toggle +dms ipc call color-picker openColor "#3f51b5" +``` + ### Target: `hypr` Hyprland-specific controls including keybinds cheatsheet and workspace overview (Hyprland only). diff --git a/quickshell/Common/KeybindActions.js b/quickshell/Common/KeybindActions.js index f5a3a34b..ab08b72d 100644 --- a/quickshell/Common/KeybindActions.js +++ b/quickshell/Common/KeybindActions.js @@ -56,6 +56,9 @@ const DMS_ACTIONS = [ { id: "spawn dms ipc call dankdash wallpaper", label: "Wallpaper Browser" }, { id: "spawn dms ipc call file browse wallpaper", label: "File: Browse Wallpaper" }, { id: "spawn dms ipc call file browse profile", label: "File: Browse Profile" }, + { id: "spawn dms ipc call color-picker toggle", label: "Color Picker: Toggle" }, + { id: "spawn dms ipc call color-picker open", label: "Color Picker: Open" }, + { id: "spawn dms ipc call color-picker close", label: "Color Picker: Close" }, { id: "spawn dms ipc call keybinds toggle niri", label: "Keybinds Cheatsheet: Toggle", compositor: "niri" }, { id: "spawn dms ipc call keybinds open niri", label: "Keybinds Cheatsheet: Open", compositor: "niri" }, { id: "spawn dms ipc call keybinds close", label: "Keybinds Cheatsheet: Close" },