-
-
Notifications
You must be signed in to change notification settings - Fork 79
Description
On sway 1.10.1-2 (from Debian Trixie repos), using foot
1.21.0-2 as a terminal emulator, the window title is set to iamb (@username:matrix.org)
(or whatever your matrix id is) upon startup, but is not reset to its previous title (in my case the name of the terminal emulator) after exiting iamb
.
From quickly skimming over the code and reading through the crossterm
docs, my impression is that this is rather a bug or missing functionality inside crossterm
.
In main.rs, setup_tty
sets up an "alternate screen" and then sets its title:
/// Set up the terminal for drawing the TUI, and getting additional info.
fn setup_tty(settings: &ApplicationSettings, enable_enhanced_keys: bool) -> std::io::Result<()> {
let title = format!("iamb ({})", settings.profile.user_id.as_str());
// [...]
crossterm::execute!(stdout(), EnableBracketedPaste, EnableFocusChange, SetTitle(title))
}
Then, on exiting, restore_tty
attempts to restore the previous state:
// Do our best to reverse what we did in setup_tty() when we exit or crash.
fn restore_tty(enable_enhanced_keys: bool, enable_mouse: bool) {
// [...]
let _ = crossterm::execute!(
// [...]
LeaveAlternateScreen,
// [...]
);
// [...]
}
The title is apparently not bound to the "alternate screen" and stays after leaving, so the natural approach would be to query the old title and save it somewhere before setting it to the iamb
-specific one.
Unfortunately, the crossterm
crate does not offer a GetTitle
feature at the moment, although this discussion on StackOverflow suggests that it should be somehow possible using ANSI escape codes (which crossterm
does seem to be using for the implementation of SetTitle).
So, it might be appropriate to create a corresponding feature request for the crossterm
crate.
Edit: Already exists over there, see: crossterm-rs/crossterm#617
A workaround could be to just not set the title at all. But it's ofc debatable whether that would be an improvement to the current situation.
I haven't tested it for other terminal emulators or window managers, for lack of finding any that implement such a title bar at all.. Maybe some do a better job handling title changes on this "alternate screen"?