FLOSS Project Planets
KDE Applications & Icons
In this rather lengthy post I talk a bit about the current issues with icons for the KDE applications I work on or use.
Let’s start with looking at what I mean with KDE applications and what the current state is, up to KDE Frameworks 6.2 and current KDE Gear 24.02. Then let’s see what will be improved in future releases.
What do I mean with ‘KDE Applications’ #If I speak about ‘KDE Applications’ here I talk about applications like Kate, Dolphin, Okular and others like that.
This means applications developed with Qt and KDE Frameworks that integrate well with the KDE Plasma desktop but are not restricted to it.
Many of this applications not just aim to work well on Linux & BSD or other open source operating systems but are ported and working well on the rather different Windows and macOS desktop. Some even are successful since years in the official Windows Store.
The above applications are part of the KDE Gear releases, but the described issues and solutions naturally are not restricted to stuff released with that.
What most of these applications have in common is that they rely on rather large parts of our Frameworks. With that they depend at least indirectly on an icon set that covers large parts of what our default icon set Breeze provides. Even if you use no icons from that icon set yourself in your application, just using the standard actions or many widgets/dialogs from Frameworks will rely on some subset of Breeze.
Current State of Icons per Desktop or Platform #When talking about the current situation of icons that depends largely on the desktop or platform you are running the KDE application on.
Let’s take a look at some (I for sure miss some that are common or loved, that doesn’t mean I disregard them, I just want to limit the scope).
KDE Plasma on Linux/BSD with Wayland/X11 #If you just aim to run on the KDE Plasma desktop with your Qt and KDE Frameworks based application, all is fine with icons, there is no problem.
The KDE project did their job, at least for Kate I never did have any issues with icons on Plasma.
Below a screenshot of Kate 24.02 running on Plasma 6. All icons are there, they are properly re-colored for the dark theme, too, including not just the used Breeze icons but for example the small Git icons in the left sidebar that Kate has bundled.
This is the vanilla state each user will get if Kate is installed on Plasma (and the dark theme is used). There are no patches done during building to achieve that nor is there any extra user configuration necessary.
Microsoft Windows #If you run Kate on Windows, the icon situation is good, too, if you use our Windows Store variant or get at build done via Craft.
See below what the current nightly of Kate looks like in some Windows 11 VM (I just started it from the unpacked ZIP, no setup needed).
In the Craft build descriptions we do some patches to ensure the Breeze icons are bundled as library and the application links with that. In addition we ensure with some more patching that our own icon engine is used to allow for the proper recoloring.
If you don’t do that patching you will end up with close to no icons or for dark theme black on black icons.
Apple’s macOS #The situation on macOS is the same as on Windows.
If you go with a Craft build of Kate, you will end up with something like below.
All icons are there and even application provided icons like our Git one are properly recolored.
Without the Craft patches Kate has more or less no icons like on Windows.
Haiku #After covering Plasma and the two large closed-source desktop operating systems, as a small excursion, look how Kate (the KF5 based version) looks if installed on Haiku with the package they provide.
Kate looks ok, system icons intermixed with Breeze as fallback icons.
GNOME #For testing this, I installed the latest Fedora Workstation in a VM. I have done no user configuration beside what the installer and initial setup wizard asked and then just installed the Kate package. The shell was even helpful to ask to do that after you just tried to start the not installed Kate.
Most icons not there, not that nice. For details about that read this post, we don’t need to re-iterate this again.
If you think: that is just Kate, let us just try Okular.
One thing that can be at least solved easily is that the icons are gone, we just install the Breeze icon set as package.
Looks ok, system icons intermixed with Breeze as fallback icons just like on Haiku. Not stylish but usable.
I was unable to trigger Kate or Okular to adjust to the dark mode GNOME provides, therefore I can not test if we end up with black on black icons there, but it is likely, as the fallback is just Breeze.
MATE #Kate and Dolphin 24.02 on MATE with dark mode on NixOS, normal system packages, Breeze icons is installed.
System icons intermixed with Breeze as fallback icons, looks not that nice. Breeze icons not readable, as recoloring is not working.
Xfce #Kate and Dolphin 24.02 on Xfce with dark mode on NixOS, normal system packages, Breeze icons is installed.
Same mix and unreadable state as on MATE.
Enlightenment #Kate 24.02 on Enlightenment with dark mode on NixOS, normal system packages, Breeze icons is installed.
Just unreadable icons, beside out own Git icon and the few colored ones.
Summary: What’s up with Icons today #The icons in KDE applications do look perfect on KDE Plasma. That should be no real surprise as many people working on these applications will test them there and KDE Frameworks and Qt are well tested on Plasma, too.
The icons look fine on Windows and macOS, too, at least for applications that got properly ported, but only thanks to patches we do in Craft. If you just grab e.g. Kate’s and the needed frameworks sources from our normal repositories, you don’t get that.
If the maintainers of the port for some OS do care, like the Haiku people, KDE applications can look fine there.
On other desktop environments it doesn’t look that great out of the box.
Unlike for the other operating systems, there the same packages without extra patches are running.
Whereas that works perfect on Plasma, we rely too much that the desktop environment running provides an icon set that has a similar coverage and naming as Breeze. As we don’t hard depend on the Breeze icons for our applications, it can even happen that just no fitting icons are there per default.
Even if that can be solved with some better package dependencies, you still end up with a patchwork look and without a Qt platform theme plugin that handles the needed recoloring to make dark mode feasible.
Getting it fixed #Fortunately, just because the status quo is not that nice, it must not stay that way.
We have more or less all needed parts to fix the situation, we did already fix it during the porting to Windows and macOS.
We just never pushed to get this stuff done on Linux and Co.
How did we solve it there?
- We have the Breeze icon set as Qt resource inside a library and link with that. That makes them a hard build and runtime dependency and easy to deploy.
- We ensure the icon engine we have in our KIconThemes framework is there and used.
- We enforce the Breeze Qt style. (this is not really icon related, but ensures an usable look’n’feel, too)
The first and the last thing are easy to do on Linux and Co., too, even with still allowing the user to override the icon set and style, but still defaulting to Breeze.
The second point is harder, as that requires at the moment a few hacks and is not 100% as good as going the Qt platform theme plugin route we use inside Plasma.
For KDE Frameworks 6.3 we worked to get that done.
See our meta issue on our GitLab instance covering that topic.
All is not perfect, we will need to get some Qt API to fully do that, but the current state is already usable.
Here a comparison with the state as we have it now in our released software compared to with the state in the current master branch on an Cinnamon desktop.
The left side is the current Kate 24.02, the right side the current master build of Kate with master Frameworks.
The hard dependency to the Breeze icon library is done in KIconThemes, if you link to that, you are guaranteed that you have Breeze icons. You can naturally just link to only the Breeze icon library on your own.
The ensuring that the proper icon engine is done with some new API in KIconThemes that application developers must opt-in for. The same for the Qt style setup, there we have API in KConfigWidgets.
For Kate the concrete changes can be found here. They are minimal and even remove some platform specific code for the style setup.
Including fallback code for pre 6.3 Frameworks compatibility of the style setting, the basic idea is:
#include <KIconTheme> #define HAVE_STYLE_MANAGER __has_include(<KStyleManager>) #if HAVE_STYLE_MANAGER #include <KStyleManager> #endif int main(...) { /** * trigger initialisation of proper icon theme */ #if KICONTHEMES_VERSION >= QT_VERSION_CHECK(6, 3, 0) KIconTheme::initTheme(); #endif QApplication yourAppInstance(...); #if HAVE_STYLE_MANAGER /** * trigger initialisation of proper application style */ KStyleManager::initStyle(); #else /** * For Windows and macOS: use Breeze if available * Of all tested styles that works the best for us */ #if defined(Q_OS_MACOS) || defined(Q_OS_WIN) QApplication::setStyle(QStringLiteral("breeze")); #endif #endif ... }In the long run, once 6.3 is the minimal version the application depends on, this is just:
#include <KIconTheme> #include <KStyleManager> int main(...) { /** * trigger initialisation of proper icon theme */ KIconTheme::initTheme(); QApplication yourAppInstance(...); /** * trigger initialisation of proper application style */ KStyleManager::initStyle(); ... }At the moment KIconTheme::initTheme() is still a bit hacky until we have proper Qt API, but that is not visible for the API user.
If we get this properly done in our applications, that will not just solve the current issue for running them in other desktop environments.
With that API in use and the now already upstreamed patches, one can build vanilla Frameworks and Kate on Windows and macOS and the icons will just work in the resulting application bundles and you get an usable style out of the box if Breeze is there.
Help Wanted! #We have now some API to help our applications to be more usable on non-Plasma installations and Windows and macOS.
We still need to make use of it and we need to improve the implementation and upstream to Qt the needed extra API to make it a real 100% replacement to what we do with the Plasma integration plugin.
If you have time to help us, show up on our meta issue.
Not just coding is needed, we for example have still a few icons that don’t recolor well, help to fix that is wanted, too.
Feedback #You can provide feedback on the matching KDE Social, reddit or Hacker News post.
Sven Hoexter: xdg and mime types - stuff I would've loved to know a week ago
Learned a few things about xdg and mimetype registration in the last week that could be helpful to have condensed in a single place.
No Need to Ship a Mailcap Mime FileIf you already ship a .desktop file (that is what ends up in /usr/share/applications/) which has a MimeType declared, there is no need to also ship a mailcap file (that is what ends up in /usr/lib/mime/packages/). Some triggers will do the conversion work for you. See also Debian Policy 4.9.
Reverse DNS Naming Convention for .desktop FilesSeems to be a closely guarded secret, maybe mainly known inside the Gnome world, but it's in the spec. Also not very widely known inside Debian if I look at my local system as not very representative sample.
Your hicolor Theme App Icon can be a Mime Type Icon as WellIn case you didn't know the hicolor icon theme is the default fallback theme. Many of us already install application icons e.g. in /usr/share/icons/hicolor/48x48/apps/ which is used in conjunction with the Icon field in the .desktop file to locate the application icon. Now the next step, and there it seems quite of few us miss out, is to create a symlink to also provide a mime type icon, so it's displayed in graphical file managers for the application data files. The schema here is simple: Take the MimeType e.g. application/x-vymand replace the / with a - and use that as file name in e.g. /usr/share/icons/hicolor/48x48/mimetypes/. In the vym case that is /usr/share/icons/hicolor/48x48/mimetypes/application-x-vym.png. If you have one use a scalable .svg file instead of .png.
This seems to be an area where Debian lacks a bit of tooling to automatically convert application icons to all the different sizes and install it in all the appropriate places. What is already there is a trigger to run gtk-update-icon-cache when you install new icons into one of the icon theme folder so they're picked up.
No Priority or Order in .desktop FilesLikely something that hapens on all my fresh installations: Libreoffice is installed and xdg-open starts to open pdf files with Libreoffice instead of evince. Now I've to figure out again to run xdg-mime default org.gnome.Evince.desktop application/pdf to change that (at least for my user). Background here is that the desktop file spec explicitly mandates "Priority for applications is handled external to the .desktop files.". That's why we got in addition to all of that mimeapps.list files. And now, after running the xdg-mime command from above, we've a ~/.config/mimeapps.list defining
[Default Applications] application/pdf=org.gnome.Evince.desktopDebian as whole seems to be not very keen on shipping something like a sensible default mimeapps.list outside of desktop environment specific ones. A quick search gave me just
$ apt-file search mimeapps.list cinnamon-desktop-data: /usr/share/applications/x-cinnamon-mimeapps.list gdm3: /usr/share/gdm/greeter/applications/mimeapps.list gnome-session-common: /usr/share/applications/gnome-mimeapps.list plasma-workspace: /usr/share/applications/kde-mimeapps.list sxmo-utils: /usr/share/applications/mimeapps.list sxmo-utils: /usr/share/sxmo/xdg/mimeapps.listWhile it's a bit anoying to run into that pdf vs Libreoffice thing every now and then, it's maybe better to not have long controversial threads about default pdf viewer, like the ones we already had about the default MTA choices. And while we're at it: everyone using Libreoffice should give a virtual hug to rene@ for taming that beast since 2010 and OpenOffice.org before.
Mike Driscoll: Ruff – The Fastest Python Linter and Formatter Just Got Faster!
I’m a little late in reporting on this topic, but Ruff put out an update in April 2024 that includes a hand-written recursive descent parser. This update is in version 0.4.0 and newer.
Ruff’s new parser is >2x faster, translating to a 20-40% speedup for all linting and formatting invocations. Ruff’s announcement includes some statistics to show improvements that are worth checking out.
What’s This New Parser?I’ve never tried writing a code parser, so I’ll have to rely on Ruff’s announcement to explain this. Basically, when you are doing static analysis, you will turn the source code into Abstract Syntax Trees (ASTs), which you can then analyze. Python has an AST module built in for this purpose. Ruff is written in Rust, though, so their AST analyzer is also written in Rust.
The original parser was called a generated parser, specifically LALRPOP. The parser requires a grammar to be defined in a Domain Specific Language (DSL), which is then converted into executable code for the generator.
Ruff’s new hand-written parser is a recursive descent parser. Follow that link to Wikipedia to learn all the nitty gritty details.
Their team created a hand-written parser to give them more control and flexibility over the parsing process, making it easier to work on the many weird edge cases they need to support. They also created a new parser to make Ruff faster and provide better error messages and error resilience.
Wrapping UpRuff is great and makes linting and formatting your Python code so much faster. You can learn much more about Ruff in my other articles on this topic:
The post Ruff – The Fastest Python Linter and Formatter Just Got Faster! appeared first on Mouse Vs Python.