Window rule for Firefox no longer sets window size

I have a window rule for Firefox that sets the size and position when I open it.

The position is still working, but the size rule stopped working a few days ago. I see Firefox open to the correct position, and the window looks like it is opening to the desired size very briefly, but then the size shrinks.

I’ve tried Force, and Remember, but no help.

Plasma 6 and Wayland.

You could try re-setting the window class using the detect window property tool to pick the details from your Firefox window, it could be a change within Firefox that has caused it.

I deleted the rule and recreated it, a few times, with Detect Window Properties.

The rule is firing and placing the window where I want it, upper left corner.

I suppose it could be a recent update of Firefox that is overriding the size that kwin applies very briefly.

Are you using the plasma title bar?
I. e. is it ticked, right click next to url bar, Costumize and tick Title Bar on the very bottom left?

Yes, Title Bar is checked.

Are you using Firefox from Flatpak, snap or a local system install?

1 Like

Local install. I download the tarball from Mozilla and unpack it directly.

If you set it to “force” it still opens at the correct size briefly and then resize?

Yes, same behavior with Apply Initially, Force, and Remember.

After I restarted Firefox and the window shrank in size, I opened the window rule, selected Apply Now for Size, and the window expanded to the size I have set in the rule.

I set Size back to Apply Initially, and New Window and New Private Window both open to the desired size.

I opened the debug console and confirmed what I thought, that the window is resizing to the “default” size (the size with no window rule).

Start Firefox with the window rule - it opens, shrinks, and I see:

frameGeometry 0,0 1283x750

Correct position, top left corner, but wrong size.

I delete the window rule and restart Firefox and see:

frameGeometry 382,182 1283x750

A centered window with the “default” 1283x750 size.

The position rule working, but the size rule getting overridden is odd.

1 Like

I have no idea what can be the problem, but perhaps you can workaround by creating a custom kwin script that “waits” a bit before resizing the window. If this may be a solution for you I can guide you through the procedure

PS it just came to my mind an old problem I had with Firefox that I solved by setting an environmental variable to force Wayland instead of x11 as backend. I think this should be the default now, but never say never. Try to look for “Firefox force Wayland” for the procedure

Thanks for the offer on a kwin script, tubbadu. I’m going to just resize after the rare reboot for now.

I do have that env variable set:

$ env | grep MOZ
MOZ_ENABLE_WAYLAND=1

1 Like

Hi tubbadu
I’m interested in the custom kwin script you offered:
“… script that “waits” a bit before resizing the window.”
I restart often and getting tired of resizing the Firefox window after it overrides my kwin rule.

Hi reteip!
I’m currently not at home so I cannot write and test the script right now, I’ll do it as soon as I can.

The idea is to write a custom kwin script (JavaScript) using the API provided by kwin: KWin scripting API | Developer

The script should register a handler for the windowAdded signal: kwin will call the handler function anytime a new window is created. The handler should check if the window is a Firefox window, and if it is it should wait some time (can be achieved with a JavaScript timer or something like that), and then resize the window

If you want to try to write it it’s not that hard, otherwise I’ll write it for you as soon as I can

(Note: the APIs are plasma 6 specific. The plasma 5 APIs are slightly different)

Okay, thank you. Yes, I’m using Plasma 6. I haven’t written a script previously, but will have a look at the link when I have more time on the weekend.
Cheers