luisbocanegra / kde-material-you-colors

Automatic color scheme generator from your wallpaper for KDE Plasma powered by Material You
https://store.kde.org/p/2136963
GNU General Public License v3.0
350 stars 6 forks source link

doesn't play nice with Wallpaper Engine KDE #199

Open cacklinglaughing opened 2 months ago

cacklinglaughing commented 2 months ago

Describe the bug Gets stuck in a bug loop when trying to use screenshot mode with wallpaper engine KDE.

To Reproduce Steps to reproduce the behavior: Install Wallpaper engine for KDE, set it to a wallpaper from there, install the screenshot helper, run kde material you colors.

Expected behavior Should take the color scheme from the background.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

[E] main: main: Could not get wallpaper Command 'Command '['journalctl', '--since', 'TIME_NOW', '--user', '-u', 'plasma-kwin_wayland.service', '-u', 'plasma-kwin_x11.service', '--output', 'cat', '-g', 'js: KMYC-desktop-window-id']' returned non-zero exit status 1.' returned non-zero exit status 1.
[D] main: main: {'light': None, 'file': None, 'monitor': 0, 'ncolor': 0, 'iconslight': None, 'iconsdark': None, 'pywal': None, 'pywal_light': None, 'light_blend_multiplier': 1, 'dark_blend_multiplier': 1, 'on_change_hook': None, 'sierra_breeze_buttons_color': None, 'disable_konsole': False, 'titlebar_opacity': 100, 'titlebar_opacity_dark': 100, 'toolbar_opacity': 100, 'toolbar_opacity_dark': 100, 'konsole_opacity': 100, 'konsole_opacity_dark': 100, 'color': None, 'klassy_windeco_outline': None, 'custom_colors_list': None, 'darker_window_list': None, 'use_startup_delay': None, 'startup_delay': 0, 'plasma_follows_scheme': None, 'pywal_follows_scheme': None, 'main_loop_delay': 1, 'screenshot_delay': 900, 'once_after_change': False, 'pause_mode': False}
[E] kwin_utils: get_desktop_window_id: Script id 0 didn't return a desktop id for screen 0: Command '['journalctl', '--since', '2024-05-16 04:15:13', '--user', '-u', 'plasma-kwin_wayland.service', '-u', 'plasma-kwin_x11.service', '--output', 'cat', '-g', 'js: KMYC-desktop-window-id']' returned non-zero exit status 1.

And

[I] plasma_utils: get_initial_mode: Using theme from stored name
[I] main: main: Wallpaper: com.github.casout.wallpaperEngineKde (screenshot): None
cacklinglaughing commented 2 months ago

Not really related to this issue but when it does work with the image plugin it says plasma-apply color scheme returned non-zero exit status 134, and when you run the command it tries to run you get

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)

I can make that a separate issue if you want.

luisbocanegra commented 2 months ago

Looks like the problem is with the code that finds the desktop (needs the window id so the screenshot-helper can take a screenshot of it). I will need you to check why the script isn't returning the window id to journalctl output.

  1. Run plasma-interactiveconsole --kwin
  2. Paste this code:
    print("SHOULD SEE THIS ON journalctl output")
    var windows = workspace.clientList()
    for (var i = 0; i < windows.length; i++) {
    let window = windows[i];
    var regex = /Desktop @ QRect\\((.*?)\\) — Plasma/;
    if (window.caption.match(regex) != null && window.screen == 0) {
        print("KMYC-desktop-window-id:", window.internalId)
    }
    }
  3. Open a second terminal and run journalctl -f
  4. With the journal running go back to the Desktop Shell Scripting Console and click Execute

In the journal output you should see something like this

May 15 22:59:05 archlinux kwin_wayland[1919]: js: SHOULD SEE THIS ON journalctl output
May 15 22:59:05 archlinux kwin_wayland[1919]: js: KMYC-desktop-window-id: {7aa1a476-ee08-4873-8644-88a5f191152c}

If you don't see any output this means logging is disabled and you need to do this https://develop.kde.org/docs/plasma/kwin/#output and restart:

# ~/.config/QtProject/qtlogging.ini
[Rules]
kwin_scripting=true
qml.debug=true

If you see an error instead please share the complete output

luisbocanegra commented 2 months ago

Not really related to this issue but when it does work with the image plugin it says plasma-apply color scheme returned non-zero exit status 134, and when you run the command it tries to run you get

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)

I can make that a separate issue if you want.

Yes please make a separate issue

cacklinglaughing commented 2 months ago

plasma-interactiveconsole --kwin

Same core dumped

luisbocanegra commented 2 months ago

What core dumped, plasma-interactiveconsole --kwin or KWin?

cacklinglaughing commented 2 months ago
@pop-os:~$ plasma-interactiveconsole --kwin
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)
luisbocanegra commented 2 months ago

That's very strange, looks like for some reason it isn't able to find the display:

My guess is you're missing the environment variable necessary to point plasmashell to the correct display from the TTY, probably DISPLAY.

I think there is a problem with how your Plasma Session is started, probably you need to configure the display manager (e.g. sddm, gdm) to start Plasma properly https://www.reddit.com/r/kde/comments/zoxmsa/i_cant_seem_to_launch_kde_plasma_desktop/

cacklinglaughing commented 2 months ago

This is how I learn those commands don't work over ssh. That command launches in the Konsole terminal. I'll do the rest of your steps now. Thank you for the help.

cacklinglaughing commented 2 months ago

I see "SHOULD SEE THIS" but no window id.

luisbocanegra commented 2 months ago

Okay, looks like it isn't matching the desktop window properly, please replace the code with this:

print("SHOULD SEE THIS ON journalctl output")
var windows = workspace.clientList()
for (var i = 0; i < windows.length; i++) {
    let window = windows[i];
    print(window.caption)
    var regex = /Desktop @ QRect\\((.*?)\\) — Plasma/;
    if (window.caption.match(regex) != null && window.screen == 0) {
        print("KMYC-desktop-window-id:", window.internalId)
    }
}

It should print the window titles of all the windows (on screen 0) including the desktop

cacklinglaughing commented 2 months ago

It shows window titles, yes. but no ids.

luisbocanegra commented 2 months ago

Yes I need to see the titles so I can adapt the matching. Last Plasma 5 version I used was 5.27.10, and the matching worked there, but apparently 5.24.7 shows Desktop window tittle differently

For context in Plasma 6 the desktop window doesn't even show titles (and I had to change the matching) so this can to change between releases.

cacklinglaughing commented 2 months ago
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: SHOULD SEE THIS ON journalctl output
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: Desktop — Plasma
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: Plasma
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: doesn't play nice with Wallpaper Engine KDE · Issue #199 · luisbocanegra/kde-material-you-colors · GitHub — Mozilla Firefox
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: - : sudo bash — Konsole
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: Steam
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: About this System — System Settings
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: Unsaved* — Spectacle
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: Download New Plasma Widgets — Plasma
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: Desktop Folder Settings — Plasma
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: ~ : bash — Konsole
May 16 22:29:59 pop-os /usr/libexec/gdm-x-session[29648]: js: Desktop Shell Scripting Console
luisbocanegra commented 2 months ago

Thanks, this one should return the id

print("SHOULD SEE THIS ON journalctl output")
var windows = workspace.clientList()
for (var i = 0; i < windows.length; i++) {
    let window = windows[i];
    var regex = /Desktop — Plasma/;
    if (window.caption.match(regex) != null && window.screen == 0) {
        print("KMYC-desktop-window-id:", window.internalId)
    }
}

Can you confirm it works? I can push fixes to plasma5 branch. But since I don't have a plasma 5 install so you will need to download the code and test manually e.g:

git clone https://github.com/luisbocanegra/kde-material-you-colors -b plasma5
cd kde-material-you-colors
rm -rf build
# Creatine and activate virtual environment
mkdir -p build/testenv
python -m venv build/testenv
source build/testenv/bin/activate

# Install project to environment
pip install -e .
pip install pywal16
echo -e "Done"
echo -e "\nRun build/testenv/bin/kde-material-you-colors"

If I recall correctly the widget is also broken for that version, if you want to help testing that too let me know and I will try to support 5.24.7 without breaking the latest Plasma 5 version which i can test in a VM.

luisbocanegra commented 2 months ago

If you want to make the change yourself here's the line you have to change https://github.com/luisbocanegra/kde-material-you-colors/blob/b2f99bc2982a3fdaface77bf2ac3f445c9b74555/src/kde_material_you_colors/utils/kwin_utils.py#L111 to var regex = /Desktop — Plasma/;

cacklinglaughing commented 2 months ago

Yes this top script returns an id

luisbocanegra commented 2 months ago

Good, let me know if you want to make/test/submit the change by yourself and feel free to send me an email to luisbocanegra17b at gmail dot com or telegram (same user as github) if you have any question or just want to test the patches

luisbocanegra commented 2 months ago

Just pushed https://github.com/luisbocanegra/kde-material-you-colors/commit/432c87555667a57bee9201694cf583afaf540b44 in case you want to try it out.

Btw now I am wondering if that string is translated as I never tested a language other than English...

cacklinglaughing commented 2 months ago

Seemingly same issue

luisbocanegra commented 2 months ago

Hmm will try fixing it after https://github.com/luisbocanegra/kde-material-you-colors/issues/126 and the Open Build Service packages are done.

cacklinglaughing commented 2 months ago

I could upgrade to Plasma 6, I'm not quite sure how seeing as all I did to install KDE over GNOME in the first place was apt-install kde-standard.

luisbocanegra commented 2 months ago

AFAIK there is no Plasma 6 packages for ubuntu yet and it may take a while before it is available (could be until october according to some random reddit comment). I you don't want to wait you can switch to other distribution https://community.kde.org/Distributions that ships Plasma 6 by default like fedora KDE