Yin-Yang icon indicating copy to clipboard operation
Yin-Yang copied to clipboard

Refactor DBus plugin and its child plugins

Open heddxh opened this issue 10 months ago • 19 comments

Working on the following:

  • [x] refactor parent class of DBus plugin, avoid using cli but using pyside6 dbus package, since some distros like Arch using qdbus6 as binary name but some distros are not.
  • [x] Port wallpaper(_kde) plugin to use DBus
  • [x] Port gtk-kde-plugin to the new DBus plugin, using dconf and xsettingsd as fallback
  • [x] konsole-plugin to the new DBus plugin

heddxh avatar Apr 17 '24 03:04 heddxh

By the way, is it possible to push the linter/formater rules to the repo?

heddxh avatar Apr 17 '24 03:04 heddxh

By the way, is it possible to push the linter/formater rules to the repo?

We are using flake8 with default configurations. Do you want to change something?

l0drex avatar Apr 17 '24 13:04 l0drex

Refer to logging doc, the basicConfig() is called after addHandler so it doesn't work.

Can't we just add the handlers after the config?

l0drex avatar Apr 17 '24 13:04 l0drex

yes that's ok, but when debugging we maybe don't need the notification?

heddxh avatar Apr 17 '24 14:04 heddxh

We are using flake8 with default configurations. Do you want to change something?

My flake8 complains a lot like line length and sort order. And I should manually turn off my formatter(black) in case it makes a lot of changes across code files. It's not a big problem but if we use the same formatter life will be easier😃

heddxh avatar Apr 17 '24 16:04 heddxh

yes that's ok, but when debugging we maybe don't need the notification?

I'd like to keep it in, just to keep the variances between developer version and normal user version low. Also, it might help if something goes wrong at an unexpected time.

l0drex avatar Apr 18 '24 18:04 l0drex

My flake8 complains a lot like line length and sort order. And I should manually turn off my formatter(black) in case it makes a lot of changes across code files. It's not a big problem but if we use the same formatter life will be easier😃

I see. I don't use any automatic formatter, but I also have many warnings from flake8 as I don't regularly run it (which I probably should). So yeah, please push it! Maybe in a different PR though, with all files formatted.

l0drex avatar Apr 18 '24 18:04 l0drex

Might be interesting: https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Wallpaper.html

l0drex avatar Apr 18 '24 19:04 l0drex

Might be interesting: https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Wallpaper.html

Surprised to know even wallpaper has its portal. I will change my code to use it.

heddxh avatar Apr 19 '24 15:04 heddxh

Might be interesting: https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Wallpaper.html

I only found xdg-portal-gtk impl this interface: https://github.com/flatpak/xdg-desktop-portal-gtk/blob/main/src/wallpaper.c , but can't find it on DBus session bus.

图片

Also I don't see any similar/related code for xdg-portal-kde. But they have plasma-apply-wallpaperimage and can apply wallpaper to all virtual desktop, maybe I will use that.

heddxh avatar Apr 20 '24 07:04 heddxh

Have you tried to use setWallpaper in org.kde.kuiserver: PlasmaShell/org.kde.PlasmaShell in the KDE plugin? It is also available in org.kde.plasmashell.

I prefer to use the dbus over the command line, as I hope that we can get rid of the command line completely and can remove the flatpak permission at some point.

l0drex avatar Apr 22 '24 15:04 l0drex

It seems like plasma-apply-wallpaperimage just using dbus under the hood, so it's work fine! But for Gnome, dbus-monitor suggests that they use Gvariant as serialization data 😢 , so I don't know how to get rid of gsettings...

heddxh avatar Apr 22 '24 15:04 heddxh

There is a variant class in qts dbus lib

l0drex avatar Apr 22 '24 21:04 l0drex

emmm, I don't know how to get this(I change /org/gnome/desktop/background/picture-options in dconf-editor and below is from dbus-monitor):

method call time=1713841847.551184 sender=:1.562 -> destination=ca.desrt.dconf serial=48 path=/ca/desrt/dconf/Writer/user; interface=ca.desrt.dconf.Writer; member=Change
   array of bytes [
      2f 6f 72 67 2f 67 6e 6f 6d 65 2f 64 65 73 6b 74 6f 70 2f 62 61 63 6b 67
      72 6f 75 6e 64 2f 70 69 63 74 75 72 65 2d 6f 70 74 69 6f 6e 73 00 00 00
      2e 31
   ]
signal time=1713841847.581724 sender=:1.53 -> destination=(null destination) serial=5 path=/ca/desrt/dconf/Writer/user; interface=ca.desrt.dconf.Writer; member=Notify
   string "/org/gnome/desktop/background/picture-options"
   array [
      string ""
   ]
   string ":1.53:user:1"          

And unluckily: https://forum.qt.io/topic/140253/uint-argument-in-dbus-call-with-python/ . It seems if there is a method need uint as arguments , then we can't call it unless involve in another dependency like https://pypi.org/project/uint

heddxh avatar Apr 23 '24 03:04 heddxh

Such as KDE's setWallpaper: 图片

screenNum take a uint32 😢

heddxh avatar Apr 23 '24 07:04 heddxh

It seems if there is a method need uint as arguments , then we can't call it unless involve in another dependency like https://pypi.org/project/uint

Seems like I already had that problem somewhere, as I have created that post :laughing: I probably should start documenting when I tried something, and it didn't work out.

Either way, in that case, I would prefer to stick to the old implementation using the dbus of the KDE wallpaper plugin.

l0drex avatar Apr 23 '24 11:04 l0drex

Seems like I already had that problem somewhere, as I have created that post 😆

I didn't find out until you said it lol😂 Don't know why QT guys let such a regression remain till now... and reading their documentation is like a nightmare.

heddxh avatar Apr 23 '24 16:04 heddxh

Still working on adding some tests and cleaning my code

heddxh avatar Apr 25 '24 11:04 heddxh

Today I discover that I should edit katerc manully to make konsole profile within has correct color scheme... Maybe other KDE applications need similar terrible hacking 😢

heddxh avatar Jun 09 '24 12:06 heddxh