Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke CmdArgs from Kwin script is ignored #2

Closed
r0skar opened this issue Apr 6, 2024 · 4 comments
Closed

Invoke CmdArgs from Kwin script is ignored #2

r0skar opened this issue Apr 6, 2024 · 4 comments

Comments

@r0skar
Copy link

r0skar commented Apr 6, 2024

When I run this in my terminal, the notification shows up as expected:

❯ qdbus nl.dvdgiessen.dbusapplauncher /nl/dvdgiessen/DBusAppLauncher nl.dvdgiessen.dbusapplauncher.Exec.CmdArgs "notify-send" "test"

However, this call from a Kwin script does nothing:

callDBus(
  "nl.dvdgiessen.dbusapplauncher",
  "/nl/dvdgiessen/DBusAppLauncher",
  "nl.dvdgiessen.dbusapplauncher.Exec",
  "CmdArgs",
  "/usr/bin/notify-send",
  "test"
);

Note: the kwin script itself works and the call is made. For example, when I use it with Cmd, /usr/bin/konsole the konsole pops up. The logs (journalctl -b | grep dbus) are completely empty.

@DvdGiessen
Copy link
Owner

DvdGiessen commented Apr 6, 2024

Similar to #1, I'm suspecting the problem might be that second argument to CmdArgs should be a list, but is given a string. So the call probably fails with a type error.

Can you try passing a JavaScript array, something like this:

callDBus(
  "nl.dvdgiessen.dbusapplauncher",
  "/nl/dvdgiessen/DBusAppLauncher",
  "nl.dvdgiessen.dbusapplauncher.Exec",
  "CmdArgs",
  "/usr/bin/notify-send",
  ["test"]
);

EDIT: And since callDBus is asynchrounous and the DBus service might even have to be autostarted first, you won't immediately get a type error thrown in the JavaScript code; since that function call has already returned before the type error even happens.

@r0skar
Copy link
Author

r0skar commented Apr 6, 2024

Unfortunately, using an array does not seem to make a difference. Nothing happens. The journal logs are empty and adding a catch is also never triggered (not sure if that is even supported in kwin) - same is true if i add a callback function as the final argument.

@DvdGiessen
Copy link
Owner

DvdGiessen commented Apr 6, 2024

Hm, I was hoping that it would automatically convert it to a StringList correctly, but I think it's trying to transmit it as a VariantList instead.

After digging a little bit I found the KWin function doesn't do any special conversion, nor does the QJSValue code. So the JS array is converted to a QVariantList instead of the QStringList we would need: Because when the time comes to convert this to a DBus type it must be specifically a QStringList to get converted to the correct StringList type.

So it would seem there currently is no way to call a DBus function from KWin which requires a QStringList argument. For that to be possible someone would probably need to extend the KWin JS API with an explicit constructor for a QStringList. The toStringList() method seemingly can help with that, it will convert to a QStringList if all the variants within can be converted to QStrings.

@DvdGiessen
Copy link
Owner

Closing since this is not really a bug or something to fix in dbus-app-launcher but is a limiation in the KWin JS API that would need to be addressed there.

If the arguments you need to pass do not change, you could try to work around this by creating a simple script file that does not require any arguments and calling that from your KWin script.

I've also opened #3 as a feature request that could perhaps provide an alternative way to mitigate this KWin JS API limitation by adding a new method that would employ shell-like command line parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants