DvdGiessen / dbus-app-launcher

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

Add method which parses command from a string #3

Open DvdGiessen opened 8 months ago

DvdGiessen commented 8 months ago

To make it easier to execute a command line given as a string without first having to split the string in the calling application, we could add a method that parses a string into a command, arguments, and perhaps even environment variables, similar to how the shell would parse such a command line.

The shellwords package seems to be perfect for this.

This will also help work around the issue noted in #2, namely that there's no easy way to call a DBus method with a StringList argument in the KWin JS API.

r0skar commented 7 months ago

I think that makes a lot of sense and (imo) makes the behavior more intuitive. Even the naming of the actions (Exec.Cmd) suggest any "valid" command should work.

DvdGiessen commented 4 weeks ago

I've implemented a first version of it using the mentioned package in the parse-cmd branch (diff). ~It still needs some cleaning up (abstracting reused code into separate functions for readability)~, and I ran into an issue in shellwords causing it to not parse things correctly, which would be nice to resolve before merging this here.

EDIT: Cleaned up the code a bit (diff), so now all that's left is integrating the fixes that have been happening in shellwords as well.