How to center a new window on the screen? #5501
Answered
by
luanbt21
bokettoCode
asked this question in
Q&A
-
What Operating System(s) are you running on?Windows Which Wayland compositor or X11 Window manager(s) are you using?No response WezTerm version20240203-110809-5046fc22 Ask your question!I went through the documentation but couldn't find the answer. I want the new WezTerm window to immediately take on a specified size and be centered on the screen. How can I achieve this? |
Beta Was this translation helpful? Give feedback.
Answered by
luanbt21
Jun 2, 2024
Replies: 2 comments 4 replies
-
you can try it wezterm.on("gui-startup", function(cmd)
local screen = wezterm.gui.screens().main
local ratio = 0.7
local width, height = screen.width * ratio, screen.height * ratio
local tab, pane, window = wezterm.mux.spawn_window(cmd or {
position = { x = (screen.width - width) / 2, y = (screen.height - height) / 2 },
})
-- window:gui_window():maximize()
window:gui_window():set_inner_size(width, height)
end) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
bokettoCode
-
When there is a high-resolution screen, cols = 100, rows = 35, otherwise based on the screen percentage (1920 * 0.65, 1080 * 0.80) wezterm.on("gui-startup", function(window)
local screen = wezterm.gui.screens().active
if screen.width == 1920 and screen.height == 1080 then
local width, height = screen.width * 0.65, screen.height * 0.80
local tab, pane, window = wezterm.mux.spawn_window {
position = {
x = (screen.width - width) / 2,
y = (screen.height - height) / 2,
origin = 'ActiveScreen'
}
}
-- window:gui_window():maximize()
window:gui_window():set_inner_size(width, height)
end
end) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can try it
author comment