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

Terminal background not updated when image file content changes #8471

Closed
luxzg opened this issue Dec 3, 2020 · 5 comments
Closed

Terminal background not updated when image file content changes #8471

luxzg opened this issue Dec 3, 2020 · 5 comments
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason.

Comments

@luxzg
Copy link

luxzg commented Dec 3, 2020

Environment

Windows build number: Microsoft Windows NT 10.0.19042.0
Windows Terminal version (if applicable): 1.4.3243

Steps to reproduce

Keep WT opened. Change settings.json, add background-image, save json. Image gets applied to running terminal window. Open image and change it without changing json - doesn't get updated. Add a space to json, save (to have new date modified) - still doesn't change background.

Expected behavior

Simply, if asset used for background-image (and I assume other assets like icons and similar) change, wt.exe should pick it up. Or at least provide a key or right-click function to force-reload the config and all assets used in it.

Actual behavior

Nothing happens, even though image file itself has new content. Restarting wt.exe will load a new asset, but that means losing session.

More details of what I'm doing

I was pondering if to open a new issue, or use #8231 , as base issue seems the same. But not to pollute the other issue, I'm opening this one, if need be merge them if you deem needed.

Anyway, I'm working on a crude way to update background in terminal depending on what I'm doing. Eg. if I SSH to server No.1, change wallpaper to show Ubuntu logo + IP/hostname of the server here I'm connected. Then when I disconnect and connect to other server No.2, switch logo to CentOS + new IP/hostname. I know I could in theory have a profile for each server, but with almost hundred profiles, it wouldn't be very productive.

So I've made a Powershell script that can change wallpaper and append text to it, so in theory I can make it a module and a function, and instead calling ssh root@10.10.10.10 Id' just be calling something like FancyWtSsh -IP 10.10.10.10 which would establish connection and change the wallpaper.

Thing is, if I use DynamicImage.png in settings.json and I change the content of the image on the fly, wallpaper doesn't reload. Just changing time modified of settings.json doesn't trigger the change either, if the image name is still the same. Even adding random space somewhere in config (like a comment) won't cause a reload, as long as the image name is still the same. So I literally need to change something like background-image: 10.10.10.10.png to background-image: 10.10.10.20.png whenever I change hosts, which makes it too much trouble, I can just as well then have a profile for each server with it's own image and scroll through them endlessly, as I wouldn't want to touch settings.json all that much, certainly not in a scripted way (call me cautios).

To tie into the issue as reported in #8231, similar thing probably happens with wallpaper changes. If you have rotating wallpapers on desktop, and wt.exe using those, when desktop rotates, pointer to image name stays the same, but content of the image asset changes, and wt.exe doesn't pick that up. So hopefully, we can squash multiple issues with one fix, and try to detect date/time of any asset that's used by settings.json, and update live terminal accordinly. Or if that's not the solution, even a simple "F5" style of keybinding that force-reloads config would be good enough in my case. It's not perfect, but it's a workaround I'm OK with.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Dec 3, 2020
@zadjii-msft
Copy link
Member

First off - that's a very clever use of the Terminal. I dig it. I believe there's a PowerShell module laying around somewhere in another repo on GitHub that can be used for modifying the WT settings on the fly - maybe that would help here?

I'm betting that this is actually a XAML thing. I'd reckon that they're the one's caching the file path->contents on load of the image, and just re-using the loaded image. I'd doubt there's a way to tell XAML to manually flush this cache...

@Don-Vito
Copy link
Contributor

Don-Vito commented Dec 3, 2020

@luxzg, @zadjii-msft - please see #7906 (comment).

The reporters there have a similar need to change the look and feel to distinguish between SSH sessions.
The idea is to change the icon, background, etc. based on the title bar regex.
It will deprecate the need for powershell script.

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Dec 3, 2020
@DHowett
Copy link
Member

DHowett commented Dec 3, 2020

I'm sorry, I don't believe it's reasonable for an application displaying an image -- ANY application, not just Terminal -- to have to care about the image's content on disk changing. If somebody replaces cmd.exe while Terminal is running, should it relaunch it?

What goes on the screen, and what is running in the terminal, is a point-in-time snapshot of the state at the last settings load.

This is very, very clever. It's also very unusual.

@DHowett DHowett closed this as completed Dec 3, 2020
@DHowett DHowett added the Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason. label Dec 3, 2020
@luxzg
Copy link
Author

luxzg commented Dec 4, 2020

@Don-Vito - thanks, I'll monitor that thread, it's covers my needs nicely

@DHowett - I will agree to disagree here, as plenty of applications monitor such changes, well, at least good ones, some examples are Notepad++ monitoring if your opened files changed outside the app to offer you to reload new version, many office apps do the same (as part of collaboration features), and so on. And I'm aware it's perhaps lots of work, that's why I proposed a "hot-reload" button or keybinding as a way around the monitoring unneccessary files, and just putting it on the user to do a forced reload.

Anyway, comment in that 7906 seems like something to watch, so I'll do that, hopefuly it gets implemented.

Thanks all for contributing to the discussion!

@DHowett
Copy link
Member

DHowett commented Dec 5, 2020

(I appreciate you understanding, what with my admittedly crabby response. 😄)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason.
Projects
None yet
Development

No branches or pull requests

4 participants