korikori/ideapad-perf

Kde applet

Closed this issue · 12 comments

Hello there, how would I go about using the applet in kde? I have tried creating a desktop entry for it and using that as a widget, but wasn't successful. Any help is greatly appreciated.

Hi there, and thanks for trying the app! The applet uses GTK3, which is Gnome's GUI toolkit. I have no idea how that would work on KDE without some conversion effort.

Two questions:

  1. Do you have GTK3 and ruby-gtk3 installed (package names may differ across distributions)?
  2. What output and/or error messages do you see in the terminal when you run ideapad-perf-tray.rb?

Thanks for your reply!
1: Yes, I have both installed.
2: Gtk-CRITICAL **: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed from /usr/lib/ruby/gems/3.0.0/gems/gobject-introspection-3.4.5/lib/gobject-introspection/loader.rb:616:in invoke'
from /usr/lib/ruby/gems/3.0.0/gems/gobject-introspection-3.4.5/lib/gobject-introspection/loader.rb:529:in block in define_method' from ideapad-perf-tray.rb:5:in

'` is the output when I try to run it directly from the terminal

Not really sure about this error, but line 5 in the script loads the applet's icon - possibly you don't have any GTK iconsets installed, or they're handled differently in KDE?
Regardless, can you try downloading and running this version of the applet script which should load a pre-packaged icon (taken from the Flattery GTK theme - note: you don't have to download this, I'm just mentioning it for attribution purposes)? The two files should remain in the same directory.

ideapad-perf-tray.zip

Unfortunately I am still getting errors, tried the new format since the included one is deprecated as it turns out, no luck with that either :(
ideapad-perf-tray.rb:7:in

': 'Gdk::Pixbuf' has been deprecated. Use 'GdkPixbuf::Pixbuf'.
/usr/lib/ruby/gems/3.0.0/gems/gdk_pixbuf2-3.4.5/lib/gdk_pixbuf2/deprecated.rb:48:in new': GdkPixbuf::Pixbuf.new(path) is deprecated. Use GdkPixbuf::Pixbuf.new(:file => path) instead. Gtk-CRITICAL **: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed from rbgobject.c:369:in set_pixbuf'
from ideapad-perf-tray.rb:7:in <main>'

Oh right - I played around the deprecation warnings and left the "older" variant uncommented. I don't think that this will resolve the problem, but just to confirm, did you try with the following:

si.pixbuf = GdkPixbuf::Pixbuf.new(file: "#{__dir__}/preferences-system-power.svg")

Anyway I'll try to set up a testing environment with KDE later today/tomorrow. I guess I'll boot from a live USB - please send me the name and version of your distribution so that I can reproduce it. Thanks.

edit: I think I found a similar bug - here's a question that was asked there:

Are you using Wayland or X11? Do you have a scaling factor other than 1 (e.g. 200% in Gnome Settings/Display)?

Yes, I have tried that one, the output is Gtk-CRITICAL **: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed from rbgobject.c:369:in set_pixbuf'
from ./ideapad-perf-tray.rb:7:in <main>'
Thank you so much for spending your time on this, you are insanely kind!
I use arch linux and have all the dependencies installed that you have mentioned, I can post a package list if you think that would help but I doubt the problem is caused by a conflict. Let me know if I can help in any way.
edit: just saw your edit: I am using wayland and the scaling factor is the default setting.

Please note that this is the first ever bug request to a project of my own (even if it's a very small project), so I'm very enthusiastic about helping you with it 😃
So looking through other similar bugs that I'm discovering, the problem is most likely not in KDE nor the icons, but between GTK and Wayland. I will continue digging to see what could be causing it and how to resolve it permanently.

In the meantime, can you try running this in the terminal to try opening the applet with X11 instead
GDK_BACKEND=x11 ./ideapad-perf-tray.rb
You may need to install this package to do so: xorg-xwayland

You were absolutely right, it works perfectly with x11 specified. Guess I'll run the script on startup with GDK_BACKEND=x11 specified. Thank you so much, I am very thankful <3 Have fun with all your projects

For anyone who wants to use this in kde:
1: Open kde settings, navigate to autostart and click Add -> Add login script, then specify the ruby file which @korikori has helped me to fix above.
2: After adding the script, click Properties, navigate to Application, then add GDK_BACKEND=x11 before the script path, hit OK, then the script should autostart with the correct settings after a reboot.

Glad that it works with this workaround - I'll add it to the project's readme. Can you do one last test and try running the unmodified tray script from the packages with GDK_BACKEND=x11 - if my understanding is correct, the modifications in this thread have been largely irrelevant to the problem.

FTR: I've done some more reading and it turns out that Wayland has absolutely no support for GTK3's StatusIcon object, which itself is deprecated in GTK3. There are a couple of projects that bring the system tray icon back to "modern" DE/WMs, such as libappindicator, but Ruby's bindings for it are very outdated and a pain to build on Arch. For such a small applet, the sensible approach would be to rewrite it in something like Python, which I don't want to do at this time (but may decide to do in the future). Anyway, for all intents and purposes, this is a "wontfix", plus for now, we have a working workaround.

You are right, the original script works with the GKD_BACKEND=x11 argument

Great to know! Thanks again for reporting and for testing. Will close this now and add to the Readme file.