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

Add option to synchronize single instance terminals #59

Open
SuperDuperDeou opened this issue Dec 29, 2024 · 3 comments
Open

Add option to synchronize single instance terminals #59

SuperDuperDeou opened this issue Dec 29, 2024 · 3 comments

Comments

@SuperDuperDeou
Copy link

SuperDuperDeou commented Dec 29, 2024

As time goes on, more and more terminal support for single instance mode.

With single instance, only one process of the terminal is ever up, if another terminal process is start, it exits immediately, and the old process spawns the new window.

This is usually desirable: it saves on load times and memory usage, but if the terminal is being started as part of a script, the script will misinterpret the process exiting immediately as the task being completed, thus the need for a way to force the terminal to not run in single instance mode, if needed.

X-TerminalArgSynchronous should contained the argument to make the new process terminate only when the window is closed. This can be achieved by still opening the window in single instance mode, but keeping the process launched by the script alive until the window is closed (ex. Kitty's --wait-for-single-instance-window-close) (preferred), or disable single instance mode for that window.

If X-TerminalArgSynchronous is not set or set but empty, it is assumed that the terminal does not support single instance mode, or that it is disabled (a.k.a. the terminal is synchronous by default).

@SuperDuperDeou SuperDuperDeou changed the title Add option to disable single instance mode Add option to synchronize single instance terminal Dec 29, 2024
@SuperDuperDeou SuperDuperDeou changed the title Add option to synchronize single instance terminal Add option to synchronize single instance terminals Dec 29, 2024
@arrowd
Copy link

arrowd commented Jan 27, 2025

Why not just place this flag in Exec=?

@SuperDuperDeou
Copy link
Author

For the purposes of this flag, we can roughly group terminals in 3 types:

  • Xterm-like: Terminals that do not support single instance mode. They're assumed to be synchronous and this does absolutely nothing.
  • Kitty-like: Terminals that do not support single instance mode, and the synchronous flag still opens the terminal window with the main process, leaving the calling process as a lightweight dummy process. While adding X-TerminalArgSynchronous is the proper way of doing this, yes, you can get away baking the synchronous arg into Exec and this change wouldn't be necessary.
  • Wezterm-like: Terminals that support single instance mode, and the synchronous flag opens a full new instance of a terminal process. With these terminals, baking the synchronous flag into Exec= is exactly the same as running it with without single instance mode. You generally want to take advantage of the single instance capabilities: it saves on system resources and the terminal window opens more quickly, but there are times where you really want the terminal window to be synchronous, and you'd rather take the resource hog only when you really need to, hence this proposal.

@arrowd
Copy link

arrowd commented Feb 7, 2025

This can be achieved by still opening the window in single instance mode, but keeping the process launched by the script alive until the window is closed (ex. Kitty's --wait-for-single-instance-window-close)

I didn't get that part. Let's say I have a Kitty window open with some work I'm doing. Then I run a script that uses this flag and it causes Kitty window to create a new "tab" for the command from the script. Now the script won't continue until I close both "tabs"? I have to interrupt my work in the first "tab"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants