DvdGiessen / dbus-app-launcher

A simple service that allows executing a program via D-Bus.
MIT License
4 stars 1 forks source link

Invoke CmdArgs with multiple arguments #1

Closed r0skar closed 8 months ago

r0skar commented 8 months ago

I am experimenting with this and was wondering how to invoke a command with multiple arguments? I hope this fake shell session helps to illustrate my current issue.

# Works as expected
❯ ydotool mousemove -x 100 -y 100

❯ qdbus nl.dvdgiessen.dbusapplauncher /nl/dvdgiessen/DBusAppLauncher nl.dvdgiessen.dbusapplauncher.Exec.CmdArgs "ydotool" "mousemove" "x" "100" "y" "100"
Invalid number of parameters

❯ qdbus nl.dvdgiessen.dbusapplauncher /nl/dvdgiessen/DBusAppLauncher nl.dvdgiessen.dbusapplauncher.Exec.CmdArgs "ydotool" "mousemove -x 100 -y 100"

❯ journalctl -b | grep dbus
Apr 06 14:28:35 incitatus systemd[4137]: Started dbus-:1.2-nl.dvdgiessen.dbusapplauncher@156.service.
Apr 06 14:29:20 incitatus dbus-app-launcher[1431494]: ydotool: Unknown command: mousemove -x 100 -y 100

Multiple args do not work and if I try to use multiple arguments as the final param, they get interpreted as a string and not individual args?

DvdGiessen commented 8 months ago

The args parameter takes a list of strings, but the syntax qdbus to create such a list (instead of interpreting them as separate arguments) isn't immediately obvious:

qdbus nl.dvdgiessen.dbusapplauncher /nl/dvdgiessen/DBusAppLauncher nl.dvdgiessen.dbusapplauncher.Exec.CmdArgs ydotool "(" mousemove -x 100 -y 100 ")"

Arguments enclosed between "(" and ")" are interpreted as a list.

r0skar commented 8 months ago

Thanks for the quick reply! I have actually started to experiment with different syntaxes. Started with brackets first - it would have taken me a little while to reach quoted parenthesis :)