How can I automatically resize and position the LibreOffice Writer window on macOS Sequoia?

I want the Writer window to open at one-third of my iMac’s screen width and the full available screen height, centred horizontally, while the Dock is hidden (my default setting).

This should happen whenever I launch Writer, whether it opens with a new, empty document or I open an existing .odt file by double-clicking it in Finder.

Is there a way to achieve this automatically, ideally without having to resize or reposition the window manually each time?

So there are two parts of the problem - triggering and actions (that is pretty much all Keyboard Maestro is really).

The action in this case is fairly simple, something like:

Then the trigger just needs to be whenever you want this to happen.

So a macro group that is specific to LibreOffice Writer, and then triggers for Focused Window trigger. Probably the focussed window changes would be sufficient. But if you find cases where it is not happening and you want it to, then you can add other triggers, potentially a manual trigger to catch extra unusual cases.

To the last bit:

The Dock will be hidden if you have "Automatically hide and show the Dock" turned on in System Settings and your pointer is outside the Dock's activation area.

Are you saying you want to turn on auto-hide as part of the macro because you normally have the Dock showing all the time?

The pointer position part is just a "Move Mouse" Action using any absolute coordinates outside the activation area.

No my Dock is always hidden. I’m a Clean Desktop Person (CDP).

I’m doing a similar thing, minus dock hiding (and with added moving-to-Space) actions. If I understand right, the issue is that the dock hide/show shortcut is to enable/disable Dock hiding entirely, rather than just hiding the dock?

In which case, I’m wondering if a simple ‘Pause for x seconds’ action before resizing the window would work for you?

This macro triggers whenever LibreOffice (the whole app) launches, and:

  • Pauses for 0.2 seconds between each action
  • Then waits until LibreOffice is the front window (ie. the app’s opened)
  • Pauses for 0.5 seconds to give the Dock time to auto-hide as a failsafe
  • Resizes the LibreOffice window

You can also do the same whenever LibreOffice activates (if it’s already open, and you bring it to the front again), if that’s what you prefer.

If you want to get more specific within LibreOffice itself, you should be able to make the resize action apply only to Writer windows:

You’d probably want to set up a Switch/Case action for the resize actions if so, though. (I can’t test this part, as my LibreOffice doesn’t show app names in the window (?!), but it should work.)

All of that’s where I’d start, anyway. Though the KM gurus may have cleaner ways of doing it :slight_smile:

Then it "should just work". SCREENVISIBLE(Main,Height) ignores the presence of the Dock when the Dock is set to auto-hide, expanding the window "behind" the Dock so it extends from the menubar to the bottom of the screen.

If LibreOffice isn't playing nice and you have to wait until the Dock is hidden again, pop in a "Pause Until" -- @lbdm, I'd be interested to know if this works for you:

list 1 is a somewhat hidden property of the Dock, containing the coordinates of the top-left corner. When the Dock is hidden the y coordinate -- item 2 of the list -- is the bottom-edge of the screen, same value as the screen's height.

You could do similar if you're a "Dock to the right side" person -- use item 1, which will be SCREEN(0,Width) when the Dock is hidden.

"Dock to the left side" could be trickier...

I concur, the first part does just work - although adding in the AppleScript makes the macro hang for me. That said, I'm on Tahoe so maybe that's why. But it does seem like it shouldn't be needed!

Working fine here on both Sequoia and Golden Gate, so I'm not sure why Tahoe would have an issue. I don't use Spaces, though.

You could try running the following demo -- if you execute it when the pointer is over (and so revealing) the Dock it should pause until you mouse off the Dock when the macro will then pop the "Display Text":

Delay Test.kmmacros (3.5 KB)

Just tried the macro. Works if the dock is positioned on bottom; doesn't work if dock is positioned to left or right sides of screen. (Also doesn't work if SCREEN(0,Height) is changed to SCREEN(0,Width).)

That said, as @ALYB is the one with their dock hidden (and I generally don't have my dock hidden), it's more important that it works for them rather than me :slight_smile:

It should work for a right-side Dock if, as mentioned, you compare item 1 of the coordinates list to the screen width.

Remember, the coordinates are the current top-left corner of the Dock -- it's the x coordinate of a right-side Dock that changes, the y of a bottom-edge Dock.

Which is why I thought a left-edge Dock would be difficult -- how can the left edge of something jammed to the left change? But it turns out that the Dock doesn't "expand" from it's hidden position, it slides in -- so a hidden left-edge Dock's left edge is beyond the edge of the screen.

So for my current display arrangement, Main display on the right and the Dock on the left-edge of the left display:

...the working "Pause" is:

So I've found out that a) it is possible, in fact it's easy, and b) the Dock on the left does my head in even more than the Dock on the right... Every day's a learning day!

Confirmed that works in Tahoe now!

Hopefully @ALYB can combine your (excellent) AppleScript sleuthing and my (as ever) bodged-together trigger-on-launch window resizing to get something that works for them :slight_smile:

This is how I solved it.

Placed in a macro group only for LibreOffice.