starkle

Fix LibreOffice Flatpak Wayland Icons on KDE

LibreOffice uses the generic ugly Wayland icon on KDE when installed from Flathub. It's a known issue without a reliable workaround, even using KDE's "window rules".

Well, I finally found the window rules needed to force the correct icons. It's pretty hacky, but at least it works.

Follow this guide or paste my rules at the bottom to a .kwinrule file and import it.

The trick is that each LibreOffice app needs two window rules, described below. I'm still not exactly sure why, but it seems like LibreOffice changes its "Window Class" -- which KDE uses to match the window -- between two states, each of which need a rule.

Let's start with LibreOffice Writer. Add a rule like below:

And then the other one (this took me forever to figure out):

This rule is because sometimes LibreOffice uses soffice as the window class, which makes it harder for it to determine which icon to use. The regular expression determines this by using the window title, which happens to always end with the name of the LibreOffice app AFAICT.

Repeat this rule creation pattern for each app. You can use the table below to reference the important details. There will be 14 rules at the end. Wow.

App Rule 1. Window Class Rule 2. soffice Title Regex Desktop file name
Writer libreoffice-writer Writer$ org.libreoffice.LibreOffice.writer
Calc libreoffice-calc Calc$ org.libreoffice.LibreOffice.calc
Impress libreoffice-impress Impress$ org.libreoffice.LibreOffice.impress
Draw libreoffice-draw Draw$ org.libreoffice.LibreOffice.draw
Base libreoffice-base Base$ org.libreoffice.LibreOffice.base
Math libreoffice-math Math$ org.libreoffice.LibreOffice.math
Generic libreoffice (Substring match) n/a org.libreoffice.LibreOffice

The last Generic rule must be placed below the other rules. It will ensure any other LibreOffice windows, such as the splash screen and the home page, use the basic LibreOffice window.

It may be ridiculous to have 14 rules to fix the icons of a single program, but just think of the productivity gained. You can know at a glance exactly what a window is, instead of flipping your desk at the sight of a Wayland icon, sobbing about why such a basic seeming issue hasn't been fixed yet. Or maybe that's just me.


To save time, paste the following content into a .kwinrule file and import it from the Window Rules settings page. Make sure to drag the "catch-all" rules below the others after importing.

[Fix icon: LibreOffice Base]
Description=Fix icon: LibreOffice Base
desktopfile=org.libreoffice.LibreOffice.base
desktopfilerule=2
wmclass=libreoffice-base
wmclassmatch=1

[Fix icon: LibreOffice Base (soffice)]
Description=Fix icon: LibreOffice Base (soffice)
desktopfile=org.libreoffice.LibreOffice.base
desktopfilerule=2
title=Base$
titlematch=3
wmclass=soffice
wmclassmatch=1

[Fix icon: LibreOffice Calc]
Description=Fix icon: LibreOffice Calc
desktopfile=org.libreoffice.LibreOffice.calc
desktopfilerule=2
wmclass=libreoffice-calc
wmclassmatch=1

[Fix icon: LibreOffice Calc (soffice)]
Description=Fix icon: LibreOffice Calc (soffice)
desktopfile=org.libreoffice.LibreOffice.calc
desktopfilerule=2
title=Calc$
titlematch=3
wmclass=soffice
wmclassmatch=1

[Fix icon: LibreOffice Draw]
Description=Fix icon: LibreOffice Draw
desktopfile=org.libreoffice.LibreOffice.draw
desktopfilerule=2
wmclass=libreoffice-draw
wmclassmatch=1

[Fix icon: LibreOffice Draw (soffice)]
Description=Fix icon: LibreOffice Draw (soffice)
desktopfile=org.libreoffice.LibreOffice.draw
desktopfilerule=2
title=Draw$
titlematch=3
wmclass=soffice
wmclassmatch=1

[Fix icon: LibreOffice Impress]
Description=Fix icon: LibreOffice Impress
desktopfile=org.libreoffice.LibreOffice.impress
desktopfilerule=2
wmclass=libreoffice-impress
wmclassmatch=1

[Fix icon: LibreOffice Impress (soffice)]
Description=Fix icon: LibreOffice Impress (soffice)
desktopfile=org.libreoffice.LibreOffice.impress
desktopfilerule=2
title=Impress$
titlematch=3
wmclass=soffice
wmclassmatch=1

[Fix icon: LibreOffice Math]
Description=Fix icon: LibreOffice Math
desktopfile=org.libreoffice.LibreOffice.math
desktopfilerule=2
wmclass=libreoffice-math
wmclassmatch=1

[Fix icon: LibreOffice Math (soffice)]
Description=Fix icon: LibreOffice Math (soffice)
desktopfile=org.libreoffice.LibreOffice.math
desktopfilerule=2
title=Math$
titlematch=3
wmclass=soffice
wmclassmatch=1

[Fix icon: LibreOffice Writer]
Description=Fix icon: LibreOffice Writer
desktopfile=org.libreoffice.LibreOffice.writer
desktopfilerule=2
wmclass=libreoffice-writer
wmclassmatch=1

[Fix icon: LibreOffice Writer (soffice)]
Description=Fix icon: LibreOffice Writer (soffice)
desktopfile=org.libreoffice.LibreOffice.writer
desktopfilerule=2
title=Writer$
titlematch=3
wmclass=soffice
wmclassmatch=1

[Fix icon: LibreOffice catch-all]
Description=Fix icon: LibreOffice catch-all
desktopfile=org.libreoffice.LibreOffice
desktopfilerule=2
wmclass=libreoffice
wmclassmatch=2

[Fix icon: LibreOffice catch-all (soffice)]
Description=Fix icon: LibreOffice catch-all (soffice)
desktopfile=org.libreoffice.LibreOffice
desktopfilerule=2
wmclass=soffice
wmclassmatch=1