mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-15 07:35:20 -04:00
update(ipc): docs & dms ipc list
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 <target> <function> [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()
|
||||
})
|
||||
}
|
||||
|
||||
+44
-27
@@ -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 <target> <function> [args...]")
|
||||
fmt.Println("Usage: dms ipc call <target> <function> [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 <target> <function>")
|
||||
}
|
||||
|
||||
// ensureFontCache rebuilds the fontconfig cache if user-configured fonts are missing while skipping defaults
|
||||
func ensureFontCache() {
|
||||
if _, err := exec.LookPath("fc-list"); err != nil {
|
||||
|
||||
+21
-1
@@ -6,6 +6,18 @@ DankMaterialShell provides comprehensive IPC (Inter-Process Communication) funct
|
||||
dms ipc call <target> <function> [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).
|
||||
|
||||
|
||||
@@ -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" },
|
||||
|
||||
Reference in New Issue
Block a user