Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting config options inside wezterm.on() does not apply settings #6366

Open
BrayanLope5 opened this issue Nov 6, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@BrayanLope5
Copy link

What Operating System(s) are you seeing this problem on?

Linux Wayland

Which Wayland compositor or X11 Window manager(s) are you using?

Hyprland

WezTerm version

wezterm 20240203-110809-5046fc22

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

No, and I'll explain why below

Describe the bug

I am trying to change the default_prog from inside an event. Not sure this is the correct terms to use, I know a little bit of python and fish but am an not a developer.
I have tried other events instead of gui-startup, I have tried changing the setting from the global scope, just like any other setting, but mux.all_windows() always seems to report zero windows on the first loading of the config file. I've used wezterm.log_info() to check. This makes it useless since the default program will have been launched already by the time we get the correct number of windows reported.
The default_prog variable does get the correct value but it doesn't seem to be applied to the config. I am under the impression that gui-startup should run before the default program. Am I not understanding how Lua's scope rules work?

To Reproduce

No response

Configuration

wezterm.on('gui-startup', function(cmd)
  local window_names = #mux.all_windows()

  if window_names == 0 then
    -- Attach zellij session when there are no wezterm gui windows open.
    config.default_prog = { '/usr/bin/zellij', 'attach', '--create', 'options', '--default-shell', '/usr/bin/fish' }
  else
    -- If there is at least one wezter gui dindow already open, open zellij welcome
    config.default_prog = { '/usr/bin/zellij', '--layout', 'welcome' }
  end
end)

Expected Behavior

For the default program of my choosing to be launched. Instead the default shell, bash, is launched.

Logs

Debug Overlay
wezterm version: 20240203-110809-5046fc22 x86_64-unknown-linux-gnu
Window Environment: Wayland
Lua Version: Lua 5.4
OpenGL: Mesa Intel(R) HD Graphics 520 (SKL GT2) 4.6 (Compatibility Profile) Mesa 24.2.6-arch1.1
Enter lua statements or expressions and hit Enter.
Press ESC or CTRL-D to exit

Anything else?

No response

@BrayanLope5 BrayanLope5 added the bug Something isn't working label Nov 6, 2024
@BrayanLope5
Copy link
Author

Doing some more debugging it seems to be a scope problem. The callback function does not seem to change the global config, a reference of the config value seems to be necessary? But I am not sure how or where to change what is passed to the callback function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant