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

Screenshot mode doesn't work `org.kde.KWin.ScreenShot2.Error.NoAuthorized: The process is not authorized to take a screenshot` #179

Closed luisbocanegra closed 8 months ago

luisbocanegra commented 8 months ago

Describe the bug I just realized that in a fresh KDE installation screenshot mode doesn't work because I didn't add X-KDE-DBUS-Restricted-Interfaces=org.kde.KWin.ScreenShot2 to the desktop file.

It worked on my system because I had a dummy launcher just for that purpose and forgot to add it to the project ¯_(ツ)_/¯

To Reproduce Steps to reproduce the behavior:

  1. Run kde-material-you-colors
  2. Use any wallpaper that triggers screenshot mode
  3. See error in log and notification
[D] utils: kill_existing: Found previous process in PID file: '330154' killing...
[I] main: main: ###### STARTED NEW SESSION ######
[D] main: main: Installed in /home/luis/.local/pipx/venvs/kde-material-you-colors/lib/python3.11/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 "darker_window_list": empty, using fallback: None
[E] kwin_utils: screenshot_window: Couldn't take screenshot of desktop: {17424778-7e8d-490d-a8a4-a5a5d620c803}
js:: The process is not authorized to take a screenshot

Desktop (please complete the following information):

luisbocanegra commented 8 months ago

Well, solving this doesn't seem to be as straight forward as allowing access to the restricted interface like this:

[Desktop Entry]
Exec=kde-material-you-colors
Icon=color-management
Name=KDE Material You Colors
Comment=Starts/Restarts background process
Type=Application
X-KDE-AutostartScript=true
X-KDE-DBUS-Restricted-Interfaces=org.kde.KWin.ScreenShot2

The reason it doesn't work is because kde-material-you-colors is not running by its own (like a compiled program would do), but rather through the python interpreter.

One can test this by replacing the exec with the interpreter e.g. /usr/bin/python and it would immediately work. But then the point of giving this privileged access to a specific program is lost, as now any python script ran through the same interpreter could possibly make bad use of that permission and that's not good. Some solutions come to mind: