Files
LLeMbas-TTY/docs/config/lua/gui-events/gui-attached.md
T
Wez Furlong d7145561c2 Add wezterm start --domain DOMAIN --attach + gui-attached event
The motivation here was to remove some similar but not quite the same
logic that existed for starting up when using `wezterm connect`.

Now `wezterm connect DOMAIN` is implemented as `wezterm start --domain
DOMAIN --attach --always-new-process` and a little extra hand-wave to
ensure that the default domain is set correctly.

The startup events have been refactored a bit; a new gui-attached
event is emitted after attaching and starting any default programs
in the selected domain at startup.

That event can be used to maximize windows and so on, if desired.

The gui-attached event is independent of the startup command and fires
for `wezterm connect`, which `gui-startup` did not (and could not) do.
2023-01-26 15:56:11 -07:00

1.3 KiB

gui-attached

Since: nightly builds only

This event is triggered when the GUI is starting up after attaching the selected domain. For example, when you use wezterm connect DOMAIN or wezterm start --domain DOMAIN to start the GUI, the gui-attached event will be triggered and passed the MuxDomain object associated with DOMAIN. In cases where you don't specify the domain, the default domain will be passed instead.

This event fires after the gui-startup event.

Note that the gui-startup event does not fire when invoking wezterm connect DOMAIN or wezterm start --domain DOMAIN --attach.

You can use this opportunity to take whatever action suits your purpose; some users like to maximize all of their windows on startup, and this event would allow you do that:

local wezterm = require 'wezterm'
local mux = wezterm.mux

wezterm.on('gui-attached', function(domain)
  -- maximize all displayed windows on startup
  local workspace = mux.get_active_workspace()
  for _, window in ipairs(mux.all_windows()) do
    if window:get_workspace() == workspace then
      window:gui_window():maximize()
    end
  end
end)

local config = wezterm.config_builder()

return config

See also: gui-startup.