by hombre_fatal · 3mo ago · 0 comments
Meanwhile a GUI's developer has to decide to grace me with the ability to even open more than one window. "A tabbed interface will be sufficient!" -- yay, I'll never be able to view two screens of info at the same time.
It's not true for AppKit, SwiftUI, GTK, Qt, WinUI, or Electron, and I'm not sure what's left.
https://www.electronjs.org/docs/latest/api/app#apprequestsin...
and handle this event:
https://www.electronjs.org/docs/latest/api/app#event-second-...
I believe macos is the only OS that enforces single instance by default. If you start xterm five times on linux, you get five independent xterm processes.
It looks like macOS Finder tries to make it difficult to run two copies of a .app simultaneously, so I imagine many programs don't check for this case, but this is Hacker News, so we can use our hacker skills to try and do what they don't want us to: find the exe inside the bundle and run it directly from Finder, or run it from the terminal using its path. (This works for me with Ptacek's mdv app. Two copies of it end up in the dock.)
vscode, electron app, no problem opening multiple windows. Geany, gtk app, no problem opening multiple windows.
Can you give an example where this doesn't work?
But the point is that the developer has to build the app in a way that lets you do this.
Once again, there is no default with the tools I listed. You decide on how you want windowing to work and then build it.
At this point, show me examples of needing a mutex to "block" a multi-window default.
You're wrong about GTK, Qt, WinUI and Electron though. They default to "do nothing" which eliminates the ability to even know that another instance exists. You have to manually program that.
Even in SwiftUI which has the simplest way to support multiple windows with zero work, the developer has to use WindowGroup, and if they didn't then you don't get to open more than one window.
Pretty much all GUI frameworks I have worked with behave the same, and you have to actively create singleton behavior.
Then you have Mac OS which makes it hard two create multiple processes of a GUI app. Other OSs don't necessarily behave the same.
For a TUI to do the same, it wouldn’t just need to find and focus the window, but would need to trace it through the myriad ways that a TUI can be displayed. I may run a TUI inside a docker container, as part of a tmux session, over ssh. If a TUI somehow managed to focus the existing instance through those layers of wrapping, I would be very surprised, disgusted, and impressed.
So I think it’s that the end goal of “redirect user to existing instance” is infeasible, so nobody bothers to enforce a single instance, since the rest of the steps aren’t possible.
Emacs Server and tmux would both like a word. Make the current tty show the app output.
There is an opencode plugin for this opencode-pty.
Terminals + browsers is all I want for most apps.
Native GTK/QT is really good, but I only want it for "system" things like a clipboard manager or file manager settings app and things like that.
But I don't think I've run into a TUI that I couldn't have multiple instances of.
They are usually tied to specific user accounts, it's true. But that's something some people made up, and it doesn't have to be that way.
Imagine if there were no terminal/pty system. Then what, I'd have to use Claude Desktop (doesn't support multiple windows) and Finder?
So no, it's not the only argument for TUIs.
https://en.wikipedia.org/wiki/Tab_(interface)
Same with docker containers
Same with concurrency
Same with Notepad
Same with exec
Same with bsd jails
Same with copies of data in a for loop
Same with recursive functions
Same with numerous copies of image viewers showing the same jpg and txt files
...it's all arbitrary containers and arbitrary recipes to encode and decode binary