Using the plasma-interactiveconsole --kwin , I go to kwin option on top. Then copy and paste the examples from here:
They don't work. It says executed but nothing shows. I tried simple console.log or print and they also don't work. I even tried a syntax error by typing gibberish and it still says executed with nothing outputting.
The Plasma tab works, but it doesn't have access to the kwin api.
STEPS TO REPRODUCE
1. Launch plasma-interactiveconsole --kwin
2. Pick kwin in the top tab
3. write anything
Executing script at Saturday, November 6, 2021 12:16:10 AM EDT
But nothing shows up
Linux/KDE Plasma: OpenSuse Leap 15.3 KDE X11
KDE Plasma Version: 5.23.2
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
I just switched to Plasma from Gnome after they broke my workflow AGAIN(!!!) with the latest update. I am trying to port my GJS scripts to KWin and just ran into this. Oops :-(
(In reply to qq6fHY79E45suV from comment #2)
> I just switched to Plasma from Gnome after they broke my workflow AGAIN(!!!)
> with the latest update. I am trying to port my GJS scripts to KWin and just
> ran into this. Oops :-(
I just noticed the platform the bug is registered under. I'm using the latest Neon.
I just noticed in OpenSUSE Tumbleweed (kwin 5.23.5) that the kwin print output and errors are printed to the system journal. Use:
journalctl -b0 -f
This `journalctl -b0 -f` cannot print the output from script in interactive console, right?
(In reply to Andrew Shark from comment #5)
> This `journalctl -b0 -f` cannot print the output from script in interactive
> console, right?
Yes, it can.
> journalctl -g "js:" -f
Hmm, it just plainly does not work for me. The latter command is just silent. The script in interactive console is just `print("Hello")`. What else I can check? I am on Arch Linux if that matters. I see the same result (no output) in the post https://www.reddit.com/r/kde/comments/qo1jtj/kwin_scripting_console_not_working/.
The systemd logs printed in journalctl is just capturing the kwin_x11 output. It's possible that your distro doesn't capture the terminal output, or kwin restarted somehow. The journalctl workaround works fine for me OpenSUSE Tumbleweed Plasma 5.24.5.
Another workaround is to open Konsole, and run the following to restart kwin and log it's output to the Konsole window.
kstart5 -- kwin_x11 --replace
`kwin_x11 --replace` is the actual command, but `kstart5` will keep kwin running after you close Konsole. The `--` tells kstart5 to treat everything after it as a single argument (the command to run).
(In reply to Andrew Shark from comment #7)
> Hmm, it just plainly does not work for me. The latter command is just
> silent. The script in interactive console is just `print("Hello")`. What
> else I can check? I am on Arch Linux if that matters. I see the same result
> (no output) in the post
Are you on Wayland? Then logging might not work. Consider using systemd boot: https://invent.kde.org/plasma/plasma-workspace/-/wikis/Plasma-and-the-systemd-boot
Also make sure that you have logging for KWin scripts enabled:
> export QT_LOGGING_RULES='js=true; kwin_scripting=true'
Wow, that worked now. Without QT_LOGGING_RULES. I can now see `... kwin_wayland: js: Hello` messages in journal.
Thank you very much!
For google searchers. I looked here https://wiki.archlinux.org/title/KDE#systemd_startup and to ensure you have enabled systemd startup, use `systemctl --user status plasma-plasmashell.service`. If it is active, it is working.
It is also possible to use "console.info" if you are too lazy to modify environment variables and re-login, like me.