mjolnir.window

Functions for managing any window.

To get windows, see mjolnir.window.focusedwindow and mjolnir.window.visiblewindows.

To get window geometrical attributes, see mjolnir.window.{frame,size,topleft}.

To move and resize windows, see mjolnir.window.set{frame,size,topleft}.

It may be handy to get a window's app or screen via mjolnir.window.application and mjolnir.window.screen.

See the screen module for detailed explanation of how Mjolnir uses window/screen coordinates.

allwindows

mjolnir.window.allwindows() -> win[]

Returns all windows

focusedwindow

mjolnir.window.focusedwindow() -> window

Returns the focused window, or nil.

orderedwindows

mjolnir.window.orderedwindows() -> win[]

Returns all visible windows, ordered from front to back.

visiblewindows

mjolnir.window.visiblewindows() -> win[]

Get all windows on all screens that match window.isvisible.

windowforid

mjolnir.window.windowforid() -> win or nil

Returns the window for the given id, or nil if it's an invalid id.

application

mjolnir.window:application() -> app

Returns the app that the window belongs to; may be nil.

becomemain

mjolnir.window:becomemain() -> bool

Make this window the main window of the given application; deos not implicitly focus the app.

close

mjolnir.window:close() -> bool

Closes the window; returns whether it succeeded.

focus

mjolnir.window:focus() -> bool

Try to make this window focused.

focuswindow_east

mjolnir.window:focuswindow_east()

Focus the first focus-able window to the east of this one.

focuswindow_north

mjolnir.window:focuswindow_north()

Focus the first focus-able window to the north of this one.

focuswindow_south

mjolnir.window:focuswindow_south()

Focus the first focus-able window to the south of this one.

focuswindow_west

mjolnir.window:focuswindow_west()

Focus the first focus-able window to the west of this one.

frame

mjolnir.window:frame() -> rect

Get the frame of the window in absolute coordinates.

id

mjolnir.window:id() -> number, sometimes nil

Returns a unique number identifying this window.

isfullscreen

mjolnir.window:isfullscreen() -> bool or nil

Returns whether the window is full screen, or nil if asking that question fails.

isminimized

mjolnir.window:isminimized() -> bool

True if the window is currently minimized in the dock.

isstandard

mjolnir.window:isstandard() -> bool

True if the window's subrole indicates it's 'a standard window'.

isvisible

mjolnir.window:isvisible() -> bool

True if the app is not hidden and the window is not minimized.
NOTE: some apps (e.g. in Adobe Creative Cloud) have literally-invisible windows and also like to put them very far offscreen; this method may return true for such windows.

maximize

mjolnir.window:maximize()

Make this window fill the whole screen its on, without covering the dock or menu.

minimize

mjolnir.window:minimize()

Minimizes the window.

movetounit

mjolnir.window:movetounit(rect)

Moves and resizes the window to fit on the given portion of the screen.
The argument is a rect with each key being between 0.0 and 1.0.
Example: win:movetounit(x=0, y=0, w=0.5, h=0.5) -- window now fills top-left quarter of screen

otherwindows_allscreens

mjolnir.window:otherwindows_allscreens() -> win[]

Get every window except this one.

otherwindows_samescreen

mjolnir.window:otherwindows_samescreen() -> win[]

Get other windows on the same screen as self.

role

mjolnir.window:role() -> string

Returns the role of the window, whatever that means.

screen

mjolnir.window:screen()

Get the screen which most contains this window (by area).

setframe

mjolnir.window:setframe(rect)

Set the frame of the window in absolute coordinates.

setfullscreen

mjolnir.window:setfullscreen(bool) -> bool

Sets whether the window is full screen; returns whether it succeeded.

setsize

mjolnir.window:setsize(size)

Resizes the window.

settopleft

mjolnir.window:settopleft(point)

Moves the window to the given point in absolute coordinate.

size

mjolnir.window:size() -> size

The size of the window.

subrole

mjolnir.window:subrole() -> string

Returns the subrole of the window, whatever that means.

title

mjolnir.window:title() -> string

Returns the title of the window (as UTF8).

topleft

mjolnir.window:topleft() -> point

The top-left corner of the window in absolute coordinates.

unminimize

mjolnir.window:unminimize()

Un-minimizes the window.

windows_to_east

mjolnir.window:windows_to_east()

Get all windows east of this one, ordered by closeness.

windows_to_north

mjolnir.window:windows_to_north()

Get all windows north of this one, ordered by closeness.

windows_to_south

mjolnir.window:windows_to_south()

Get all windows south of this one, ordered by closeness.

windows_to_west

mjolnir.window:windows_to_west()

Get all windows west of this one, ordered by closeness.