Stable Window Placement (Position and Screen) #6041
Replies: 2 comments 2 replies
-
The features mentioned here are still of value, but I have the basic feature working. I cannot get the dynamic form working, only the static form. StaticThis uses a fixed width of 1440, which is measured from an open GUI window. It does work, though, once I fixed some logical errors. wezterm.on("gui-startup", function(cmd)
local main_screen = wezterm.gui.screens().main
local position = {
x = main_screen.width - 1440,
y = 0,
origin = "MainScreen",
}
cmd = cmd or { position = position }
wezterm.mux.spawn_window(cmd)
end) DynamicI would like to do something more dynamic, but this doesn't work: wezterm.on("gui-startup", function(cmd)
local _tab, _pane, window = wezterm.mux.spawn_window(cmd or {})
local gui_window = window:gui_window()
local dimensions = gui_window:get_dimensions()
local main_screen = wezterm.gui.screens().main
local x = main_screen.width - gui_window.pixel_width
local y = 0
gui_window:set_position(x, y)
end) This still wouldn't work because there's no way to force the spawned window to be only on the main screen and |
Beta Was this translation helpful? Give feedback.
-
You may want to look at wezterm.on('gui-attached') rather than 'gui-startup', which is what I'm using to decide where to place the initial window |
Beta Was this translation helpful? Give feedback.
-
What Operating System(s) are you running on?
macOS
Which Wayland compositor or X11 Window manager(s) are you using?
No response
WezTerm version
20240203-110809-5046fc22
Ask your question!
I'm looking at converting from iTerm2, but there's a few things that I can't quite figure out how to do — or even if they are possible. I suspect that ⅔ of what I want to do here is possible with scripting — but after three days in the weeds of WezTerm config I am drawing blanks, but the last ⅓ may require new features if they are to be supported.
Stable Window Placement
The critical feature for me is having stable window placement on the same screen when Wezterm opens (and preferably when I hit ⌘N). The way I work is generally to have all terminal windows stacked on the right side of my main (laptop) screen. To that end, in iTerm2, I have the following set in
Profiles > Default > Window
settings:The style options are Normal, Full Screen, Maximized (
window:gui_window():maximize()
), No Title Bar, Full-Width Bottom of Screen, Full-Width Top of Screen, Full-Height Left of Screen, Full-Height Right of Screen, Bottom of Screen, Top of Screen, Left of Screen, and Right of Screen.I’ve seen #5501 on how to centre a window, and I think this should be feasible — but my current solution:
isn't working in the
gui-startup
event. Because the window hasn't been spawned, I don't think I can get thepixel_width
, although it might be possible.Feature Request 1
It would be nice to add a parameter to
maximize()
to control the maximization angle.Feature Request 2
It would be nice to have logical window positioning primitives. Instead of positioning the top left corner of a window with
set_position(x, y)
, I’d want to do something likegui_window:set_logical_position { top = 0, right = 0 }
to put the windowtop
pixels from the top of the screen (more or less what they
position is now) andright
pixels from the right of the screen (this would be akin to settingx
to something likescreen.width - gui_window.pixel_width
).For the case where the window hasn't been spawned yet, it would be useful to get the predicted size of the window somehow so that
cmd.position
can be set better.Feature Request 3
It would be nice to set a screen affinity at the top level. I basically never want a terminal window on my secondary screen.
Beta Was this translation helpful? Give feedback.
All reactions