# How to Show Debug Info when Developing a Kwinscript?

**URL:** <https://discuss.kde.org/t/how-to-show-debug-info-when-developing-a-kwinscript/29118>\
**Category:** Help\
**Tags:** kwin, wayland, development\
**Created:** [February 1, 2025, 8:13am UTC](https://discuss.kde.org/t/how-to-show-debug-info-when-developing-a-kwinscript/29118 "2025-02-01T08:13:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![EatDatPie\_445](https://discuss.kde.org/user_avatar/discuss.kde.org/eatdatpie_445/32/17997_2.png) [@EatDatPie\_445](https://discuss.kde.org/u/EatDatPie_445)\
**Post date:** [February 1, 2025, 8:13am UTC](https://discuss.kde.org/t/how-to-show-debug-info-when-developing-a-kwinscript/29118/1 "2025-02-01T08:13:39Z")

</div>

Hi, I am trying to write a simple macro using kwinscript but there’s no log output.

This is my script:

```auto
let sessionHandle = null;

function initializeRemoteDesktopSession() {
    callDBus(
        "org.freedesktop.portal.Desktop",
        "/org/freedesktop/portal/desktop",
        "org.freedesktop.portal.RemoteDesktop",
        "CreateSession",
        { "handle_token": "session_token" },
        function (reply) {
            if (reply.error) {
                console.log("Failed to create RemoteDesktop session:", reply.error);
                return;
            }
            sessionHandle = reply["session_handle"];
            console.log("RemoteDesktop session initialized:", sessionHandle);

            // Request screen cast permissions with keyboard access
            callDBus(
                "org.freedesktop.portal.Desktop",
                sessionHandle,
                "org.freedesktop.portal.RemoteDesktop",
                "Start",
                { "devices": 2 }, // 2 = Keyboard device
                function (startReply) {
                    if (startReply.error) {
                        console.log("Failed to start RemoteDesktop session:", startReply.error);
                    } else {
                        console.log("RemoteDesktop session started successfully.");
                    }
                }
            );
        }
    );
}

function sendKeyEvent() {
    if (!sessionHandle) {
        console.log("No active RemoteDesktop session. Initializing...");
        initializeRemoteDesktopSession();
        return;
    }

    let device_id = 0; // Use device ID 0
    let keycode = 48; // B key (evdev keycode)
    
    // Send key press
    callDBus(
        "org.freedesktop.portal.Desktop",
        sessionHandle, // Use session handle as path
        "org.freedesktop.portal.RemoteDesktop",
        "NotifyKeyboardKeycode",
        [device_id, keycode, 1], // Press event
        function (reply) {
            if (reply.error) {
                console.log("Failed to send key press event:", reply.error);
            } else {
                console.log("B key pressed.");
                // Send key release after a short delay
                setTimeout(() => {
                    callDBus(
                        "org.freedesktop.portal.Desktop",
                        sessionHandle,
                        "org.freedesktop.portal.RemoteDesktop",
                        "NotifyKeyboardKeycode",
                        [device_id, keycode, 0], // Release event
                        function (releaseReply) {
                            if (releaseReply.error) {
                                console.log("Failed to send key release event:", releaseReply.error);
                            } else {
                                console.log("B key released.");
                            }
                        }
                    );
                }, 50); // 50ms delay to simulate a quick press
            }
        }
    );
}

registerShortcut(
    "Remap A to B",
    "Remap A to B",
    "A",
    sendKeyEvent
);

initializeRemoteDesktopSession();

```

The script first use `registerShortcut` to bind to `a`. Then the script uses `RemoteDesktop` XDG Desktop Portal to send inputs in a secure way. In this case, it’s sending the `b` key. So this script sends the input `b` when `a` is pressed.

There’s a bug in my script and I can’t debug because there’s nothing in the console. The output from `plasma-interactiveconsole --kwin` just says that the script is loaded and nothing else.

I found this [issue](https://bugs.kde.org/show_bug.cgi?id=445058#c4) using `journalctl`. It uses the command `journalctl -g "js:" -f` it also doesn’t work as it also display if the script is loaded or not.

Is there another way to check the logs of a kwinscript? And also is there a way to turn off a kwinscript? It gets really annoying when there’s a bug in my script but the `a` key is binded which doesn’t press `a`.
