Skip to content

Wednesday, 27 September 2023

Recently, I’ve stumbled across some behavior of C++ lambda captures that has, initially, made absolutely no sense to me. Apparently, I wasn’t alone with this, because it has resulted in a memory leak in QtFuture::whenAll() and QtFuture::whenAny() (now fixed; more on that further down).

I find the corner cases of C++ quite interesting, so I wanted to share this. Luckily, we can discuss this without getting knee-deep into the internals of QtFuture. So, without further ado:

Time for an example

Consider this (godbolt):

#include <iostream>
#include <functional>
#include <memory>
#include <cassert>
#include <vector>

struct Job
{
    template<class T>
    Job(T &&func) : func(std::forward<T>(func)) {}

    void run() { func(); hasRun = true; }

    std::function<void()> func;
    bool hasRun = false;
};

std::vector<Job> jobs;

template<class T>
void enqueueJob(T &&func)
{
    jobs.emplace_back([func=std::forward<T>(func)]() mutable {
        std::cout << "Starting job..." << std::endl;
        // Move func to ensure that it is destroyed after running
        auto fn = std::move(func);
        fn();
        std::cout << "Job finished." << std::endl;
    });
}

int main()
{
    struct Data {};
    std::weak_ptr<Data> observer;
    {
        auto context = std::make_shared<Data>();
        observer = context;
        enqueueJob([context] {
            std::cout << "Running..." << std::endl;
        });
    }
    for (auto &job : jobs) {
        job.run();
    }
    assert((observer.use_count() == 0) 
                && "There's still shared data left!");
}

Output:

Starting job...
Running...
Job finished.

The code is fairly straight forward. There’s a list of jobs to which we can be append with enqueueJob(). enqueueJob() wraps the passed callable with some debug output and ensures that it is destroyed after calling it. The Job objects themselves are kept around a little longer; we can imagine doing something with them, even though the jobs have already been run.
In main(), we enqueue a job that captures some shared state Data, run all jobs, and finally assert that the shared Data has been destroyed. So far, so good.

Now you might have some issues with the code. Apart from the structure, which, arguably, is a little forced, you might think “context is never modified, so it should be const!”. And you’re right, that would be better. So let’s change it (godbolt):

--- old
+++ new
@@ -34,7 +34,7 @@
     struct Data {};
     std::weak_ptr<Data> observer;
     {
-        auto context = std::make_shared<Data>();
+        const auto context = std::make_shared<Data>();
         observer = context;
         enqueueJob([context] {
             std::cout << "Running..." << std::endl;

Looks like a trivial change, right? But when we run it, the assertion fails now!

int main(): Assertion `(observer.use_count() == 0) && "There's still shared data left!"' failed.

How can this be? We’ve just declared a variable const that isn’t even used once! This does not seem to make any sense.
But it gets better: we can fix this by adding what looks like a no-op (godbolt):

--- old
+++ new
@@ -34,9 +34,9 @@
     struct Data {};
     std::weak_ptr<Data> observer;
     {
-        auto context = std::make_shared<Data>();
+        const auto context = std::make_shared<Data>();
         observer = context;
-        enqueueJob([context] {
+        enqueueJob([context=context] {
             std::cout << "Running..." << std::endl;
         });
     }

Wait, what? We just have to tell the compiler that we really want to capture context by the name context – and then it will correctly destroy the shared data? Would this be an application for the really keyword? Whatever it is, it works; you can check it on godbolt yourself.

When I first stumbled across this behavior, I just couldn’t wrap my head around it. I was about to think “compiler bug”, as unlikely as that may be. But GCC and Clang both behave like this, so it’s pretty much guaranteed not to be a compiler bug.

So, after combing through the interwebs, I’ve found this StackOverflow answer that gives the right hint: [context] is not the same as [context=context]! The latter drops cv qualifiers while the former does not! Quoting cppreference.com:

Those data members that correspond to captures without initializers are direct-initialized when the lambda-expression is evaluated. Those that correspond to captures with initializers are initialized as the initializer requires (could be copy- or direct-initialization). If an array is captured, array elements are direct-initialized in increasing index order. The order in which the data members are initialized is the order in which they are declared (which is unspecified).

https://en.cppreference.com/w/cpp/language/lambda

So [context] will direct-initialize the corresponding data member, whereas [context=context] (in this case) does copy-initialization! In terms of code this means:

  • [context] is equivalent to decltype(context) captured_context{context};, i.e. const std::shared_ptr<Data> captured_context{context};
  • [context=context] is equivalent to auto capture_context = context;, i.e. std::shared_ptr<Data> captured_context = context;

Good, so writing [context=context] actually drops the const qualifier on the captured variable! Thus, for the lambda, it is equivalent to not having written it in the first place and using direct-initialization.

But why does this even matter? Why do we leak references to the shared_ptr<Data> if the captured variable is const? We only ever std::move() or std::forward() the lambda, right up to the place where we invoke it. After that, it goes out of scope, and all captures should be destroyed as well. Right?

Nearly. Let’s think about the compiler generates for us when we write a lambda. For the direct-initialization capture (i.e. [context]() {}), the compiler roughly generates something like this:

struct lambda
{
    const std::shared_ptr<Data> context;
    // ...
};

This is what we want to to std::move() around. But it contains a const data member, and that cannot be moved from (it’s const after all)! So even with std::move(), there’s still a part of the lambda that lingers, keeping a reference to context. In the example above, the lingering part is in func, the capture of the wrapper lambda created in enqueueJob(). We move from func to ensure that all captures are destroyed when the it goes out of scope. But for the const std::shared_ptr<Data> context, which is hidden inside func, this does not work. It keeps holding the reference. The wrapper lambda itself would have to be destroyed for the reference count to drop to zero.
However, we keep the already-finished jobs around, so this never happens. The assertion fails.

How does this matter for Qt?

QtFuture::whenAll() and whenAny() create a shared_ptr to a Context struct and capture that in two lambdas used as continuations on a QFuture. Upon completion, the Context stores a reference to the QFuture. Similar to what we have seen above, continuations attached to QFuture are also wrapped by another lambda before being stored. When invoked, the “inner” lambda is supposed to be destroyed, while the outer (wrapper) one is kept alive.

In contrast to our example, the QFuture situation had created an actual memory leak, though (QTBUG-116731): The “inner” continuation references the Context, which references the QFuture, which again references the continuation lambda, referencing the Context. The “inner” continuation could not be std::move()d and destroyed after invocation, because the std::shared_ptr data member was const. This had created a reference cycle, leaking memory. I’ve also cooked this more complex case down to a small example (godbolt).

The patch for all of this is very small. As in the example, it simply consists of making the capture [context=context]. It’s included in the upcoming Qt 6.6.0.

Bottom line

I seriously didn’t expect there to be these differences in initialization of by-value lambda captures. Why doesn’t [context] alone also do direct- or copy-initialization, i.e. be exactly the same as [context=context]? That would be the sane thing to do, I think. I guess there is some reasoning for this; but I couldn’t find it (yet). It probably also doesn’t make a difference in the vast majority of cases.

In any case, I liked hunting this one down and getting to know another one of those dark corners of the C++ spec. So it’s not all bad 😉.

I might be busy early next month, so I’m posting this a few days early so I get it out of the way! I managed to do a lot of big stuff this month, and pretty happy with my pace. I still have way too many open MRs though, I really need to get that sorted.

Sorry about the shoddiness of some of the screenshots. We are the midst of our Qt6 transition, and sometimes my Breeze is broken and fell back to a built-in Qt theme. I promise it won’t look that ugly in a couple of months!

Plasma

I redid the Accessibility KCM to make it look a bit nicer, by using the newer sidebar view we use in other KCMs. This still needs some time in the oven, though.

The “new” Accessibility KCM!

The kaccess daemon now reloads it’s config files properly, causing odd behavior like the screen reader never turning off.

Tokodon

The Send button in the composer now changes depending on why you opened it.. This is an easy way to confirm you’re resending, editing and so on.

Screenshot of the new button behavior when editing a post.

I implemented a lot of UX improvements for the profile page. It’s way harder to mess up the timeline state by clicking through tabs too quickly. Oh yeah, and that’s fixed for the notification page filters too.

The settings are overhauled and using the new CategorizedSettings component which will make it easier to add more. This has already made space for granular per-account notification controls!

The new settings page. Better notification controls!

High character count posters rejoice, as the status composer is now usable for you! This will also appear in 23.08, so you don’t have to wait until the next major release.

The status composer now scrolls if it needs to.

The alignment of the top row of buttons in posts is ever so slightly fixed now so it looks prettier, and has better clickable areas.

BeforeAfter
imageimage

I ported the whole application to Qt6 declarative type registration, and other niceties. This doesn’t mean anything for users, but Tokodon should be a bit faster.

If you were ever frustrated with logging into Tokodon, fear not as in the next release the entire process is redone. I rewrote the entire UX to be way more user friendly, less buggy and it supports some cool features like a integrated authorization flow and registration!

The new registration page. You can’t view the server rules yet, but that will be added soon!

Tokodon will now show you a visible warning and explain why your account did not log in, instead of kicking you back to the login page like before:

An example of a login error. It’s even actionable!

Finally, a few media attachment improvements such as media attachments being blacked out if the blurhash is missing (which happens, apparently) and an “Alt” tag that shows up in the top right if the image has alt text. Saves me a click or two, and especially useful for video.

Showcase of the new chips.

NeoChat

I’m attempting to fix the lack of formatting when re-editing messages. It won’t be finished this month, but I’m close!

Two event source dialog changes, including it not showing any data and only showing the option if you have developer tools enabled.

The error message when your device encryption keys are somehow different than what’s currently in your database is now clearer, and tells you to log back in.

PlasmaTube

The sidebar is reorganized so more pages are separated as you might expect. There’s still some work to be done here.

There are more pages in the sidebar now, instead of being packed into one.

Added support for passing a video URL via the commandline.

Made sure PlasmaTube inhbits sleep like other well-behaving video applications when fullscreen.

Kirigami

Finally merged the Navigation Tab Bar page for Kirigami Gallery! It’s a simple example of this component that we use quite often on mobile.

The new section in Kirigami Gallery.

I changed the fullscreen image viewer used in NeoChat, Tokodon and more to stop listening to swipe events with the mouse and stop wrapping key navigation. For application developers, make sure you set the focus properly when opening it so key navigation works.

I fixed the FormArrow bug in Qt6 where it would point the wrong direction and thanks to Ivan Tkachenko for pointing out that we could use the existing enum in Qt. All consumers of this component have already been ported.

The CategorizedSettings component got some fixes as well, including the ability to filter out invisible actions (useful for hiding certain pages on other platforms, e.g. Android.) and fixing the stuck checked state. There’s still a lot of work to do on this component, but it’s a start!

KCoreAddons

I added a QML singleton for grabbing the applications’ KAboutData instead of it being reimplemented for every single QtQuick application. I have no idea why we didn’t do this before!

import QtQuick
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.coreaddons

FormCard.AboutPage {
    aboutData: AboutData
}

Qt

We are trying to adopt qmlformat in KDE. I spend a unreasonable amount of time fixing formatting, so it would be nice to have it automatically happen like we already use clang-format for with C++. I have managed to make some really good headway here, and squash lots of little nagging bugs we have hit. These have not been merged into Qt yet, but I hope we can get them reviewed soon. (If you have approver rights, I would appreciate if you took a look!)

I fixed a bug where qmlformat would indent call expressions twice causing weird indentation like this:

onTestChanged: {
fooBar(test, {
        // Testing
        "foo": "bar"
        });
}

qmlformat shouldn’t insert newlines in empty components and objects which we use in a lot of QML code. Normally qmlformat would format them like this, which wastes space and looks kinda ugly:

QtObject {
}

Oh yeah, and object declarations in arrays should look less insane.

If you use spaces to delineate groups of import statements, qmlformat should now try to preserve that instead of destroying it.

And two more small things: fixing the command line arguments not overriding anything and fixing the QML coding conventions documentation.

Monday, 25 September 2023

I had the hankering for tinkering the KDE application style. The default style by KDE, Breeze, is pretty nice as is, but there are small things I'd like to modify.

There's Klassy which is quite customizable and fun, but I don't really need all of the settings it has.

Then there's Kvantum which uses SVG files to create a theme, but they don't follow KDE colorschemes. And I dislike working with SVG files.

Both are brilliant for their usecases, but I wanted just Breeze with few changes.

Fork time!

Screenshot Zephyr style in action

So, I did what one has to do, forked Breeze and renamed everything Breeze related to Zephyr. I chose Zephyr because it was synonym for Breeze in Thesaurus lol. Also, it makes sure it's last in the list of the application styles, so people don't accidentally confuse it to Breeze.

Here's link to the repository: https://codeberg.org/akselmo/Zephyr

Installation help is also there, but feel free to make issue and/or merge requests for adding stuff like what packages one has to install for their distro.

Unfortunately due to the massive size of the Breeze Gitlab repo, I didn't want to flood Codeberg with the whole history. So, some of the history got lost. I have mentioned it in the readme file though.

After renaming all the things, the whole thing built and installed surprisingly easily.

I then implemented following:

  • Black outline setting, so the default outline has a black one around it.
    • Why? Idk looks cool. Not really other reason.
    • Yes, it can be disabled.
  • Traffic color icons in window deco
    • I am allergic to Apple but the traffic light concept just makes sense to me.
    • Also can be enabled or disabled
  • Customizable style frame and window deco outline colors
    • You can completely change the frame colors.
    • You can also make them invisible! No outlines, no frames! Fun!
  • Slightly rounder windows and buttons
    • At some point I will make a setting for these too, but now they're applied when the thing is built
  • Fitting Plasma style if you use the defaults Zephyr offers (mostly black outlines)
    • The plasma theme buttons do not match the application style in roundness, yet.
    • I am lazy and avoid working with SVG files as long as I can

Why

For fun! For learning! And I wanted to make something that is super close to Breeze (hell, it is Breeze, just few mods), but still has it's own charm and how I like seeing my desktop.

It also can work as a great test bench for others who want to see if they can modify application style.

Just rename anything Zephyr to YourForkNameHere and have fun. But it's probably better to fork the original Breeze project :)

Also, when making my own things for Breeze, it's nice to just implement them in something similar but different name so I can test the changes for longer period of time. And if I like the changes I can maybe show them to upstream.

In future, I will make it work with Plasma 6 (unless i feel lazy). Probably will have to fork Breeze then again and apply my changes. Hopefully it's not too big of a change.

Also, I will be working on the actual Breeze in future too! I hope to implement separator colors for the Plasma colorscheme, so basically you can change the color of all frames and outlines and whatnot. This kinda helped me to figure how that works as well!

All in all, good project, I keep tinkering with it and it helps me understand the Breeze styling and Qt in general more.

Revontuli and Zephyr

My colorscheme Revontuli works really well together with Zephyr. So, feel free to give them a go!

Thanks for reading as usual!

Sunday, 24 September 2023

On Thursday and Friday evenings, I went to the Matrix Community Summit at C-Base in Berlin with Tobias. It was the occasion to meet a few other Matrix developers particularly the Nheko developer, MTRNord and a few other devs whom I only knew by nickname. It was great even though I could only spend a few hours there. Tobias stayed longer and will be able to blog more about the event.

Photo of the C-Base showing a lot of electronical equipements
Photo of the C-Base showing a lot of electronical equipements

During the weekend, instead of going to the Matrix summit, I participated to the KDE Promo sprint with Paul, Aniqa, Niccolo, Volker, Joseph. Aron also joined us via video call on Saturday. This event was also in Berlin at the KDAB officem which we are very thankful for hosting us.

This sprint was the perfect occasion to move forward with many of our pending tasks. I mainly worked on web-related projects as I tried to work on a few items on my large todo list.

We now have an updated donation page, which includes the new donnorbox widget. Donnorboy is now our preferred way to make recurring donations and recurring donations are vital to the success of KDE. Check it out!

Screenshot of the website KDE.org/community/donations
Screenshot of the website KDE.org/community/donations

With Paul, we also looked at the next KDE For-pages. Two of them are now done and we will publish them in the coming weeks. There are plans for a few more and if you want to get involved there, this is the phabricator task to follow.

I also updated the KDE For Kids with the help of Aniqa. It now features the book Ada & Zangemann from Matthias Kirschner and Sandra Brandstätter that sensibilise kids to Free Software. Let me know if you have other books suggestions for kids around Free Software and KDE that we can include on our websites.

This was only a short version of all the things we did during this sprint, I will let the others blog about what they did. More blog posts will certainly pop up on planet.kde.org soon.

The sprint would have been only possible thanks to the generous donation from our users, so consider making a donation today! Your donation also helps to pay for the cost of hosting conferences, server infrastructure, and maintain KDE software.

Tuesday, 19 September 2023

Qt OPC UA – Data Type Code Generation

The type system of OPC UA permits the creation of complex and nested data types. With the merge of the generic struct decoding and encoding feature, the Qt OPC UA module has greatly improved the comfort of handling such types. But for large projects with lots of custom data types, its QVariant based interface might still feel a bit too complicated.

Continue reading Qt OPC UA – Data Type Code Generation at basysKom GmbH.

Saturday, 16 September 2023

Kraft (Github) is a desktop utility making it easy to create offers and invoices quickly and beautifully in small companies.

Today we are releasing Kraft Version 1.1 with significant improvements for users and the Krafts integration with latest software such as cmake and KDE.

It received updated dutch translations in UI and also for the manual. The application icon was fixed, and some cmake related fixes were done that make Kraft working with different versions of Akonadi that are available on different distributions.

Macros

For users, two significant improvements are included: The header- and footer texts of the documents now may contain macros that support automatic computing of values such as dates that depend on the document date. With that, it is for example easy to have for example a payment date printed out on the document, that is ten days later than the document date.

There are even more interesting macros, stay tuned for a separate post about this feature.

Insert Templates Button

The second new feature is a new button that allows to insert templates for the header- or footer text at the cursor position. Before it was only possible to replace the entire text with a template. This will give users way more flexibility how to structure template texts.

In parallel to these improvements, work is also going on in a branch for Kraft 2.0 which will enable more collaborative functions for Kraft.

Thursday, 14 September 2023

Generic Struct Handling is Coming to Qt OPC UA

OPC UA servers often use structured data types, for example when they are implementing a companion specification or exposing custom structured data types from a PLC program. Up to now, Qt OPC UA was just returning a binary blob when reading such a value and the decoding was left entirely to the user. Since OPC UA 1.04, there is a standardized way for a server to expose the data type description for custom data types. We have extended Qt OPC UA to use this information to make it much easier to encode and decode custom data types. The following article introduces the new API.

Continue reading Generic Struct Handling is Coming to Qt OPC UA at basysKom GmbH.

Tuesday, 12 September 2023

For the past few days I was at the seaside.

As my better half had some work that she needed to take with her, I also took my new laptop and when she was doing her thing, I tweaked a few small things here and there. Nothing major though, as we were still on vacation.

Games

Not that I game much these days, especially on PC1, but if I already have a Vega 8 graphic card, it would be wasteful not to at least try it.

By default I am booting into Zen kernel, as it is said to provide a smoother experience on laptops/desktops as well as with gaming.

Lutris (and Steam)

Initially installing either Lutris or Steam failed me with a SegFault, but after asking on the forums and digging through Lutris documentation, I managed to get both installed.

Then I added my Steam, GOG and Itch.io libraries to Lutris. Installing (and launching) games through Lutris is super convenient.

A problem I am still running in with though is a bit weird. Lutris offers a really nifty option to change the keyboard to US when launching a game. That is quite handy for me since my default layout in Neo2.

But the problem is that even after the game ends, (some?) GTK applications – at least Firefox, GIMP – retain US layout even after the game (or even Lutris) ends. So far I could not figure out how to fix this or work around it, apart from simply not using that option.

The few games I tried seem to run fine (e.g. Return to Monkey Island runs perfectly), but I am sure there is some performance tweaking to be made … some other day.

Mouse go whoops!

This was a bit awkward …

I have a Roccat Kone Pure mouse2, which I find to be a great programmable mouse with 12 buttons. It is marketed as a “gaming mouse”, but honestly I use it to bind some keyboard shortcuts to mouse buttons.

As is often the case with these things, to update and modify the firmware on the device itself there is a (no longer maintained, but stable) (semi-)official niche one-man Linux tool – Roccat Tools. The tool still works fine, even though it has not seen an update since 2019.

If you want to write firmware to the (mouse) device, you need write premissions to it, which is obviously and sanely, not the case the default. The packages do provide the correct UDev rules, but you still need to add yourself to the roccat group.

And here is where it got ugly.

I forgot to use --append in the usermod command … yeah, not great. Do not forget to use it.

To fix my stupid mistake, I had to log in as root (luckly I could!) and add myself to the right groups from memory. I hope I got it right 😅

Console

Nowadays I rarely use the pure TTY console, and am typically in a PTY like Konsole or Alacritty.

Regardless, when that happens, I do like having a nice environment, so I did at least some basics.

Fonts

Default console fonts are not very pretty and I needed to tweak at least the FONT_MAP to get some common Slovenian characters (č, š, ž) to work anyway, so I went font window-shopping.

There are not many console fonts – too limiting and not sexy enough for designers, I assume – but there are a few, and in the end I settled for Spleen3.

Later I noticed that Spleen is the default console font in OpenBSD since 2019, which brings me hope this font will continue to be maintained.

After refreshing my memory with the Arch wiki: Linux Console, I added the following to /etc/vconsole.conf:

KEYMAP=slovene
FONT=spleen-12x24
FONT_MAP=8859-2

I did also consider the following fonts, and here is why I did not chose them:

  • tamzen – especially its PowerLine variant did make my CLI prettier, but č, š, ž support was lacking;
  • terminus – the venerable Terminus was really close to staying my console font of choice, but I just wanted something more fun.

Mouse

Having a working mouse/touchpad is also a nice thing to have in a console, so I went and installed Consolation. It was as simple as:

yay consolation
systemctl enable consolation.service

GPM probably works fine still, but apparently its code is hard to maintain at this stage and not working great with touchpads, so I tried the much more modern Consolation.

It is very flexible, but out of the box it worked fine enough for me, so I did not mess with it right now. I may later though.

Boot splash screen

Since I had some extra time, I decided to also include a splash screen when booting.

I decided for Plymouth, as it seems more powerful and maintained than the alternatives.

After a simple yay --sync plymouth plymouth-kcm I downloaded and selected my preferred theme through the Plymouth KCM.

Then I needed to enable Plymouth by adding it to Dracut with:

/etc/dracut.conf.d/plymouth.conf:

force_drivers+=" amdgpu "
add_dracutmodules+=" plymouth "

… and generating the new sudo dracut-rebuild and reboot.

For some reason without forcing the drivers with force_drivers it would override my font settings with defaults again. Hat-tip to dalto for helping me with that issue.

To actually make it apply, I had to pass the splash kernel parameter to GRUB, as described in Arch Wiki: Kernel parameters. For now I decided not to use quiet, but I may enable it later. Eh, I did go for quiet by the end of the day. Looks nicer and I can always lnav /var/log/boot.log to see the boot logs4.

I considered making the boot silent, but at least for now, I decided not to.

Background in console

I tasted blood.

I wanted to pimp my TTY as much as I did back during my Gentoo days.

I wanted a pretty backround and frame even in my console!

Sadly, it seems there is an issue with modern kernels (5.17 and newer) and the patch that is needed to get that to work. Also FBSplash seems to not have been maintaind in a while, to the extent that even Gentoo removed it.

So, I gave up on that piece of nostalgia. Oh, well, good times …

KDE

X11 vs Wayland

After using Plasma on Wayland for a few days and then using it on X11 again, I noticed a few more nice things on Wayland:

  • Touchpad gestures exist on Wayland, but not on X11 – I am surprised to how much I look forward to the gestures being polished, now that I have a large trackpad.
  • Some things – e.g. the pop-down hints in Kate while you type – look much nicer on Wayland, but that we knew.

There are some very big caveats when using Plasma on Wayland right now though, but it is being worked on:

  • Applications do not prompt to save unsaved work, causing data loss – KDE bug № 461176 – this is a big big issue, but is being worked on.
  • When the compositor crashes or restarts, non-Qt apps are killed — work is ongoing to fix this and just recently David ”DeD” Edmundson blogged about great progress on how with Wayland this would not just get fixed, but make sessions much more robust than we have ever seen before, with added bonuses of essentially safe-states for apps, upgrading without logging out, etc. Go read DeD’s blog post, that stuff is mind-blowingly amazing!
  • Global Menu is not supported for non-Qt appsKDE bug № 424485 – I have been using an auto-hiding Global Menu for many years now, to save vertical space, but with a 14" screen, I am OK without it.

For now, I will probably switch between X11 and Wayland, depending on whether the priority of the day is a) to make sure I do not forget to save things I worked on, or b) a more shiny and fluid experience.

Disable hibernate

Since I never suspend do disk (hibernate, S4), I disabled that, so the icon in Plasma menu goes away.

Following Arch Wiki: KDE, I simply created:

/etc/systemd/sleep.conf.d/00-disable-hibernation.conf with the following in it:

[Sleep]
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

Missing packages

While I was adding a few Plasmoids to my desktop, I noticed some were missing, which also caused the TodoList Plasmoid not to work.

After asking on the forums a bit, I installed the whole Plasma metapackage with yay plasma-meta and restarted it. As for KDE Gears, I prefer to install each application separately.

While I was at it, I added a few more KCM modules as well:

yay --sync colord-kde systemd-kcm kcmsystemd kcm-wacomtablet kcm-polkit-kde sddm-kcm plymouth-kcm

What was also missing was spell-checking. Since Sonnet supports several spell-checking back-ends, I installed the Hunspell dictionaries of the languages I typically use. That should also make them available to LibreOffice.

While I was at it I also did yay --sync languagetool libreoffice-extension-languagetool to enable grammar checking in LibreOffice through the awesome LanguageTool.

Make GTK apps look Qt

To provide some better visual consistency between Qt and GTK applications, I installed kde-gtk-config to be able to chose the GTK theme also within KDE, and breeze-gtk as the theme of my choice. I say “some better visual consistency”, because some applications use GTK2, some GTK3, some GTK4, some LibAdwaita directly, so there are more variables than just “GTK”.

I decided against removal of CSD – although, I dislike them – because it seems how they are done and set up is still in flux, so fixing it for GTK3 might break some edge cases, but also still not fix it for GTK4 etc.

There is/was also a way to (try to) force GTK applications to use the KDE file chooser etc. through XDG Desktop Portal, but GNOME says that is not a feature, but a debugging tool, so until that gets introduced as a feature, I decided not to mess with it.

This was as far as I cared to push it, as I did not want things to break. If you want to do more, the Arch Wiki on Qt and GTK is a good starting point.

Plasma-ify Firefox

Firefox is a GTK application I use the most often, and it also has some quirks of its own, so I spend some extra time with it.

First I made sure the plasma-browser-integration package and Plasma integration Firefox add-on are installed. Those make sure that the browser more neatly integrates with Plasma – e.g., tabs and bookmarks show in KRunner, the Media Player plasmoid (better) shows what is playing in Firefox, native download notifications are used, Firefox integrates with KDE Connect, etc.

For the next step I had to make sure that xdg-desktop-portal and xdg-desktop-portal-kde packages are installed.

Then, following the Arch Wiki: Firefox, I added the following to my ~/.mozilla/firefox/????????.default-release/user.js (NB: ???????? is actually a random-looking set of characters and will be different for you than it is for me):

// Enables XDG Desktop Portal integration (e.g. to use KDE Plasma file picker)
// https://wiki.archlinux.org/title/Firefox#XDG_Desktop_Portal_integration
user_pref("widget.use-xdg-desktop-portal.file-picker", 1);
user_pref("widget.use-xdg-desktop-portal.mime-handler", 1);
user_pref("widget.use-xdg-desktop-portal.settings", 1);
user_pref("widget.use-xdg-desktop-portal.location", 1);
user_pref("widget.use-xdg-desktop-portal.open-uri", 1);

// Enables further KDE integration (to disable duplicated entry in Media Player)
// https://wiki.archlinux.org/title/Firefox#KDE_integration
user_pref("media.hardwaremediakeys.enabled", false);

Now I get both the open and save file dialogues from Plasma also in Firefox. The above forces a few other things to be pulled from KDE Plasma (through XDG Portals).

The easiest way to force Firefox to use server-side window decorations (e.g. how Plasma does it), is to right-click on its toolbar and select Customize Toolbar. There enable the Title Bar checkbox.5

Since I use Sidebery to organise tabs in vertical tree, I want to hide the default tab bar. To do so, I just added the following to ~/.mozilla/firefox/????????.default-release/chrome/userChrome.css:

/* Hides top tabs toolbar, so Tree Style Tabs are the only tabs available */
#TabsToolbar {
    visibility: collapse !important;
}

More complex tweaks: Firefox CSS Hacks

If you need more styling hacks, MrOtherGuy maintains a huge selection of more complex ones, together with instructions on Firefox CSS Hacks.

For help, I found the #FirefoxCSS Matrix channel very helpful.

I ultimately – but after a lot trial-and-error, because I initially forgot how I did it a decade ago – did not need MrOtherGuy’s Firefox CSS Hacks, but it is a great resource!

At least for now, I decided to use vanilla Firefox, but might move to SUSE’s Firefox KDE fork down the line, later on (or not, we will see, there seems to be some movement upstream).

Enable Bluetooth

Although Bluez was installed, I could not see any Bluetooth devices in KDE.

The problem was very simply that by default Bluetooth is not enabled on EndeavourOS in SystemD.

A quick fix was to simply run:

systemctl enable bluetooth.service
systemctl start bluetooth.service

Enable KDE Connect

KDE Connect is a great tool.

Initially it did not find my mobile phone, because of the firewall, which is by default enabled on EndeavourOS.

All it took though was to open up the Firewall KCM and there from the list of pre-defined rules find KDE Connect and add it. Super simple 😁

Emoji

I also noticed that Emoji were missing by default.

To correct that, I installed the otf-openmoji package (with limited success).

Why OpenMoji and not any of the more well known options?

Well, honestly, I have a soft spot for the underdogs. Also some of the designs there just looked cleaner and nicer to me, compared to JoyPixels, Noto or Twemoji.

OpenMoji’s monochrome designs are very clean and nice, but some symbols – like flags – just do not work in monochrome. I hope this gets fixed in the future, so a healthy mix can exist.

For some reason (at least on Arch / EndeavourOS), this Emoji font defaults to the monochrome “Black” version instead of the coloured one, I followed the hint in this comment and added the following to ~/.config/fontconfig/fonts.conf for the “Black” version to be ignored:

<!-- Block OpenMoji Black from the list of fallback fonts. -->
<selectfont>
    <rejectfont>
        <pattern>
            <patelt name="family">
                <string>OpenMoji</string>
            </patelt>
            <patelt name="style">
                <string>Black</string>
            </patelt>
        </pattern>
    </rejectfont>
</selectfont>

… but, this does not seem to work for me. In fact, even deleting the /usr/share/fonts/openmoji/OpenMoji-Black.ttf file did not fix it for me.

What did work for me though was to download the (old bitmap) CBDT version of OpenMoji-color-cbdt.ttf and installing that as a user font.

OpenMoji is open for help

If you like OpenMoji – as I do – and actually have the design skills and knowledge – unlike I do –, it would be great if you contributed to OpenMoji.

Meta key mystery

And, finally, the Meta (a.k.a. Win) key mystery …

What started happeneing was, that seemingly at random times the Meta key would just stop working. Which is really annoying since a lot of shortcuts use it. (e.g. Meta+W for the Overview, Meta+Q for the Activity Manager, Meta+Tab for quick Activity switching, …)

I tried figuring it out myself, but could not. After some time, I did figure out a work-around that it sometimes started working again, if I suspended the machine to RAM (sleep) and then woke it up again. Sometimes this would require several cycles.

So I asked for help on the EndeavourOS forums.

After further communal head-scratching, I wrote an e-mail to Slimbook’s support. And their answer came just a tiny bit quicker as someone else’s (correct) suggestion on the forum. Which is to say, both methods were very fast!

Turns out I am an idiot.

Fn+F2 is hard-coded to disable/enable the Meta key … apparently enough gamers like it that way that several manufacturers have that feature.

So what happened was, that sometimes when I pressed Ctrl+F2 to switch to Virtual Desktop 2, I would inadvertently (also) press Fn, as I am still getting used to the new keyboard. Remember, Ctrl and Fn are famously switched on ThinkPads, which were my main laptop until now.

And as for why putting the laptop to sleep would sometimes fix the issue … Well, the suspend button combination on Slimbook is Fn+F1, so I must have sometimes also pressed F2 in the process sometimes.

Next time

That was quite a chunk of work that I originally intended to do much later.

The laptop did not wake up from suspend to RAM (a.k.a. S3, sleep) a few times, so I am investigating what this is about. I will likely dedicate a separate blog post just for that.

As for the next blog post, it will be either that or something Btrfs or backup related.

hook out → going to the sea was great, but a bit too short


  1. When I play nowadays, it is usually on Nintendo Switch, as it is very convenient to play either on the TV or hand-held. 

  2. In fact, between me and my brother we have four identical ones, so one pair is being used, while the other pair is being repaired. Throughout the years these mice have seen several repairs and mods by now, with different sets of button switches, wheel encoders etc. Perhaps I should publish my take on them, if anyone is interested (drop me a line). What will I do, once – hopefully far away in the future – our Roccat mice finally fail completely, I do not know, but I suspect a trip down the DIY path with something like Ploopy

  3. I also used spleen32x64 11pt as the font in Yakuake, but kept Hack in Konsole

  4. If you have not yet, do check out lnav – it is an awesome log viewer! 

  5. If you do not see that option, you could just tell KWin to force the window title and decorations for all Firefox windows. You can add a new Window Rule through Plasma’s System Settings

Sunday, 10 September 2023

Man, I wish politics were boring, but that is never going to happen. The only way a party can improve their popularity is by being seen as different and in some way better, so we will always have parties saying exactly that: That the others are wrong and that they are better.

However, in many cases there is actually a right and a wrong way to engage with a problem, so what will happen if one side wants to become popular with the worse solution? Well, lies, propaganda and disinformation of course!

But all of that shouldn't matter. If you have any opinion at all about what policies are good or bad, you can look up for yourself if a specific party worked for or against you in the past. But who wants to figure that out in their free time, really? I certainly don't, but I did it anyway because various elections in Germany are coming up and some parties have been actively working against what the KDE community stands for:

https://wordsmith.social/felixernst/deutscher-wahlkampf-aus-einer-kde-perspektive (German)

Yes, that article is only in German. I don't really want to translate it because I would need to provide a lot of local background knowledge as context. I am also already annoyed enough by Germany's political landscape that I wouldn't want to spend the time figuring out how to explain it to an international readership with varying backgrounds and severity of disinformation.

In any case, I wish all of you will be able to elect the party that is the least corrupt and whose actions (or lack thereof) are the least likely to kill innocent people. Happy voting!

Saturday, 9 September 2023

Screenshot of version 0.5.4

This release introduces a wide variety of new features and several fixes.

New Animation Features

A script element has been removed to ensure Planet works properly. Please find it in the original post.

One new feature is the overshoot keyframe preset, with this comes the ability to edit the keyframe transition to go beyond the previously imposed limits.

A script element has been removed to ensure Planet works properly. Please find it in the original post.

Added support for "auto orienting" groups and layer, automatically aligning their rotation with the motion path.

Composition Overhaul

This is a major change of how compositions are handled internally, all compositions now share the same attributes and features, without having a "main" composition that dictates how other compositions should behave.

This fixes several minor inconsistencies that were previously caused by this distinction.

Additionally, when saving formats that support a single composition, Glaxnimate will automatically export the active composition, simplifying the exporting process and enhancing overall project management.

File Formats

The main new feature is support for Adobe After Effects Project files (.aep). This allows you to open animations created in AE directly within Glaxnimate.

While not all AE features are supported, most animations should work fine.

There have been several improvements to other file formats as well.

SVG

Now importing a non-animated SVG uses the same duration as the current composition, making it easier to use SVG files as assets.

Support has been added for importing SVG with animated path shapes, as well as animateMotion.

Animations within <defs> now are imported correctly.

Some other import improvements include fixes to group opacity, clip paths, anchor point detection, and detection of the start and end frames (The latter fix also applies to AVD import).

Exporting to SVG has received numerous improvements such as better star shape conversion, miter limit being correctly exported, removing unnecessary stroke shapes, and fixing export of precompositions with stretched time or time offsets.

Lottie

Lottie import has received several improvements as well.

Now Glaxnimate supports loading lottie files with radial gradient highlights, split positions, and auto-oriented layers. Zig zag import has also been improved.

There have also been fixes to dotLottie import, now images and custom metadata are properly supported.

Open / Save Improvements

Along with format support, this release introduces several quality of life improvements to the open / save flow.

Saving a file sets the default export path to the folder the file is saved to, this is to avoid having to select the folder again if you want to export the file into multiple formats.

When possible, backup files are saved in the same directory as the file being edited. Previously backup files were stored exclusively in the glaxnimate data directory, which made them more difficult to access.

Directly opening a static image file sets the animation to 1 second rather than 0.

A new setting has been introduced in the preferences dialog that allows toggling between the system native file dialog and the Qt widgets one.

There have also been improvements in the script API to handle import / export plugins: the new window.choose_option() method shows a dialog to display a selection from a list, and exception from I/O plugins now show in the script console.

More Accurate Animations

Animation rendering has received several fixes. Some files might look slightly different but now the animation appears as intended.

Easing curves for keyframes now offer more accurate timing. Some issues with the rendering of the last frame for layers and hold keyframes have been resolved, also the UI no longer makes frames outside the composition range available for selection.

There have been visual fixes for masks, trim path and offset path modifiers.

Minor Features

RAL Classic Palette

Added support for loading image assets from the web rather than limiting to local files.

Added built-in palettes with RAL and web colors and the palette selector has been improved to accommodate these large palettes.

Holding Ctrl now allows you to snap the transform position handle to the x or y axis for precise adjustments.

Finally some buttons in the advanced page of the trace dialog have been fixed.

Experimental Android APK

There's now an arm64 APK download for Android, providing you with the opportunity to experience Glaxnimate on your mobile device.

This is experimental so not all features might be available and the user interface hasn't been polished yet.