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
395 stars 6 forks source link

Screenshot Helper is not working properly. #228

Closed ChengCheng0v0 closed 3 days ago

ChengCheng0v0 commented 3 days ago

Describe the bug I am using a third-party dynamic wallpaper plugin, so I need to use the Screenshot Helper to extract colors based on the wallpaper. However, it does not work correctly on my system. I tried to run the kde-material-you-colors command, but the error seems to be a permission issue.

To Reproduce Steps to reproduce the behavior:

  1. Run the kde-material-you-colors command in the terminal.
  2. An error occurs, and the program fails to run.

Terminal output:

[chengcheng_0v0@Cheng-Arch-PC ~]$ kde-material-you-colors
[D] utils: kill_existing: Found previous process in PID file: '108223' killing...
[I] main: main: ###### STARTED NEW SESSION ######
[D] main: main: Installed in /usr/lib/python3.12/site-packages/kde_material_you_colors
[D] config: eval_conf: Config "on_change_hook": empty, using fallback: None
[D] config: eval_conf: Config "color": empty, using fallback: None
[D] config: eval_conf: Config "custom_colors_list": empty, using fallback: None
[D] config: eval_conf: Config "darker_window_list": empty, using fallback: None
[D] config: eval_conf: Config "qdbus_executable": empty, using fallback: None
[E] wallpaper_utils: get_desktop_screenshot: Command '['/usr/bin/kde-material-you-colors-screenshot-helper', '{d257cb15-b096-46c8-870d-b83b5ca46951}', '/tmp/kde-material-you-colors-desktop-screenshot-chengcheng_0v0.png']' returned non-zero exit status 1.
[E] wallpaper_utils: screenshot: Command '['/usr/bin/kde-material-you-colors-screenshot-helper', '{d257cb15-b096-46c8-870d-b83b5ca46951}', '/tmp/kde-material-you-colors-desktop-screenshot-chengcheng_0v0.png']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/utils/wallpaper_utils.py", line 101, in screenshot
    screenshot_taken = get_desktop_screenshot(
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/utils/wallpaper_utils.py", line 219, in get_desktop_screenshot
    screenshot_taken = kwin_utils.screenshot_window(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/utils/kwin_utils.py", line 224, in screenshot_window
    raise subprocess.CalledProcessError(
subprocess.CalledProcessError: Command '['/usr/bin/kde-material-you-colors-screenshot-helper', '{d257cb15-b096-46c8-870d-b83b5ca46951}', '/tmp/kde-material-you-colors-desktop-screenshot-chengcheng_0v0.png']' returned non-zero exit status 1.
[W] main: main: Screenshot mode enabled, Waiting 900.0s between updates
[E] main: main: Could not get wallpaper cmd ['/usr/bin/kde-material-you-colors-screenshot-helper', '{d257cb15-b096-46c8-870d-b83b5ca46951}', '/tmp/kde-material-you-colors-desktop-screenshot-chengcheng_0v0.png']
Error: Failed to capture window {d257cb15-b096-46c8-870d-b83b5ca46951}: The process is not authorized to take a screenshot

[D] main: main: {'light': False, 'file': None, 'monitor': 0, 'ncolor': 0, 'iconslight': 'Papirus-Light', 'iconsdark': 'Papirus-Dark', 'pywal': False, 'pywal_light': False, 'light_blend_multiplier': 1, 'dark_blend_multiplier': 1, 'on_change_hook': None, 'sierra_breeze_buttons_color': False, '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': False, 'custom_colors_list': None, 'darker_window_list': None, 'use_startup_delay': False, 'startup_delay': 0, 'plasma_follows_scheme': False, 'pywal_follows_scheme': False, 'main_loop_delay': 1.0, 'screenshot_delay': 900.0, 'once_after_change': True, 'pause_mode': False, 'screenshot_only_mode': True, 'scheme_variant': 5, 'chroma_multiplier': 1.0, 'tone_multiplier': 1.0, 'qdbus_executable': None}
[E] wallpaper_utils: get_desktop_screenshot: Command '['/usr/bin/kde-material-you-colors-screenshot-helper', '{d257cb15-b096-46c8-870d-b83b5ca46951}\njs:', '/tmp/kde-material-you-colors-desktop-screenshot-chengcheng_0v0.png']' returned non-zero exit status 1.
[E] wallpaper_utils: screenshot: Command '['/usr/bin/kde-material-you-colors-screenshot-helper', '{d257cb15-b096-46c8-870d-b83b5ca46951}\njs:', '/tmp/kde-material-you-colors-desktop-screenshot-chengcheng_0v0.png']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/utils/wallpaper_utils.py", line 101, in screenshot
    screenshot_taken = get_desktop_screenshot(
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/utils/wallpaper_utils.py", line 219, in get_desktop_screenshot
    screenshot_taken = kwin_utils.screenshot_window(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/utils/kwin_utils.py", line 224, in screenshot_window
    raise subprocess.CalledProcessError(
subprocess.CalledProcessError: Command '['/usr/bin/kde-material-you-colors-screenshot-helper', '{d257cb15-b096-46c8-870d-b83b5ca46951}\njs:', '/tmp/kde-material-you-colors-desktop-screenshot-chengcheng_0v0.png']' returned non-zero exit status 1.
[I] main: main: Wallpaper: None (screenshot): None
^CTraceback (most recent call last):
  File "/usr/bin/kde-material-you-colors", line 5, in <module>
    from kde_material_you_colors.main import main
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/main.py", line 507, in <module>
    main()
  File "/usr/lib/python3.12/site-packages/kde_material_you_colors/main.py", line 503, in main
    time.sleep(config.read("main_loop_delay"))
KeyboardInterrupt

Expected behavior Screenshot Helper should work properly, and kde-material-you-colors should extract colors from the screenshot and apply them.

Screenshots null

Desktop (please complete the following information):

Additional context I checked issue #211 and tried to follow the solution mentioned there, but it had no effect. It seems to be unrelated to my issue.

luisbocanegra commented 3 days ago

Error: Failed to capture window {d257cb15-b096-46c8-870d-b83b5ca46951}: The process is not authorized to take a screenshot

I have seen this problem in the past without a clear indication of what makes the helper not have enough permissions, but one thing I noticed was that running without the full executable path often worked, can you try running the helper manually with these commnads?

  1. Using absolute path, should give the same error /usr/bin/kde-material-you-colors-screenshot-helper $(qdbus6 org.kde.KWin /KWin org.kde.KWin.queryWindowInfo | grep uuid | awk '{print $2}') /tmp/screeenshot_test.png
  2. Executable name only kde-material-you-colors-screenshot-helper $(qdbus6 org.kde.KWin /KWin org.kde.KWin.queryWindowInfo | grep uuid | awk '{print $2}') /tmp/screeenshot_test.png
luisbocanegra commented 3 days ago

Looks like the reason for this might be that you still have leftover helper from a local installation of the helper?

I can reproduce the error if both the helper from the AUR and the one installed manually with ./install-screenshot-helper.sh are in the system

ChengCheng0v0 commented 3 days ago

Thank you for your reply!

I was in the process of trying out the two commands you provided, but I just received your new response.

Here are the results from running the two commands:

[chengcheng_0v0@Cheng-Arch-PC ~]$ /usr/bin/kde-material-you-colors-screenshot-helper $(qdbus6 org.kde.KWin /KWin org.kde.KWin.queryWindowInfo | grep uuid | awk '{print $2}') /tmp/screeenshot_test.png
Failed to capture window {00b24c71-a7d0-431d-bb9c-454dc07a14a4}: The process is not authorized to take a screenshot
[chengcheng_0v0@Cheng-Arch-PC ~]$ kde-material-you-colors-screenshot-helper $(qdbus6 org.kde.KWin /KWin org.kde.KWin.queryWindowInfo | grep uuid | awk '{print $2}') /tmp/screeenshot_test.png
Failed to capture window {00b24c71-a7d0-431d-bb9c-454dc07a14a4}: The process is not authorized to take a screenshot

I installed the kde-material-you-colors package using yay and then installed the Screenshot Helper using the ./install-screenshot-helper.sh script. Are you suggesting that the kde-material-you-colors package already includes the Screenshot Helper, and by using the script, I might have caused a conflict?

luisbocanegra commented 3 days ago

I installed the kde-material-you-colors package using yay and then installed the Screenshot Helper using the ./install-screenshot-helper.sh script. Are you suggesting that the kde-material-you-colors package already includes the Screenshot Helper, and by using the script, I might have caused a conflict?

Yes, the AUR package includes the helper, having the one installed with the script is creating this conflict. The reason this might be happening is because KWin might not be recognizing the permission file from the local executable and .desktop file as there are two now.

Removing the local one should fix the permission error:

rm ~/.local/share/applications/kde-material-you-colors-screenshot-helper.desktop ~/.local/bin/kde-material-you-colors-screenshot-helper
ChengCheng0v0 commented 3 days ago

Thank you!

Removing the extra .desktop file solved the issue, and now it’s working perfectly.

Once again, thank you for your help and for creating such a great tool. I wish you all the best! :)

luisbocanegra commented 3 days ago

You're welcome!

Actually, it seems to recognize the permissions properly, it's just that the python back-end returns the first executable found:

https://github.com/luisbocanegra/kde-material-you-colors/blob/e3e29041883b10c0ab02bbeacd931216ddb2a035/src/kde_material_you_colors/utils/utils.py#L371C1-L390C45

Still there is no reason to have both installs, I will add a note about this to the README.