SUMMARY Using the plasma-interactiveconsole --kwin , I go to kwin option on top. Then copy and paste the examples from here: https://develop.kde.org/docs/plasma/kwin/#quick-start-desktop-console 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 4. Execute OBSERVED RESULT Executing script at Saturday, November 6, 2021 12:16:10 AM EDT Runtime: 11ms But nothing shows up EXPECTED RESULT Any output! SOFTWARE/OS VERSIONS 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
Can confirm.
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. But that output contains a lot of other stuff to. A more specific command to retreive output from JavaScript-based KWin and Plasmshell scripting is: > 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 > https://www.reddit.com/r/kde/comments/qo1jtj/ > kwin_scripting_console_not_working/. 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[994]: 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.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3042
I also noticed that at first run, the datetime is not bold (expected: bold as all other launches).
Created attachment 160274 [details] The not bold timedate text at first launch
I can confirm what @hexchain says, `console.info` works - for me nothing else was producing output at all, but this finally did.
It took me a while to figure out that "console.info" in comment 13 was meant to be used instead of "print" in the scripts... That does indeed work.
The workaround isn't super reliable working with the journal. Almost always the output is in the journal immediately after the dbus calls, but occasionally I find it's delayed by some milliseconds. So you have to poll or retry. A bigger issue is you can't have multiple scripts running in parallel since it's this global journal output. You'd have to add some tag to each print statement to make sure you grep output from the right script only.