terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Feature request: wt.exe should display shortcut icon in taskbar

Open brucejo75 opened this issue 5 years ago • 14 comments

Description of the new feature/enhancement

With a shortcut I can assign a wt.exe configuration per shortcut. But when the shortcut is run the wt.exe icon is shown not the shortcut icon.

This makes it hard to choose configurations short of opening each wt.exe window.

cmd.exe is an example of doing this well, it displays the icon of the shortcut when it is run. And each shortcut gets their own icon set in the taskbar for all windows started with that shortcut.

This would make it easy to set up specialized configs of wt.exe and be able to navigate between them easily.

This is similar to:

  • #1871, but is not required to be dynamic.
  • #1868, but is not about changing any escape sequences

cmd.exe example

cmd.exe essentially has this feature. This should be able to be replicated by the Windows Terminal?

Create a shortcut1, target: C:\Windows\System32\cmd.exe Add it's own icon. (Icon1)

Create a shortcut2 target: C:\Windows\System32\cmd.exe Add it's own icon. (Icon2)

  1. Start shortcut1, Icon1 displays in the taskbar.
  2. Start shortcut2, Icon2 displays in the taskbar even though it is just a 2nd instance of cmd.exe.

Here is a screenshot:

CMD exe Icons

What you are looking at: 2 separate cmd.exe sessions on the left & 2 different bash.exe sessions on the right. Each with their own taskbar icon. Very easy to choose the right session from the taskbar.

brucejo75 avatar Mar 02 '20 01:03 brucejo75

I'm mildly worried that this is a platform bug. I'd bet that shortcuts to app execution aliases always use the app's icon, and not the shortcut's. We could pretty easily test this by adding a shortcut to ubuntu.exe (or another distro's launcher) and changing that icon.

zadjii-msft avatar Mar 02 '20 14:03 zadjii-msft

Works as described above with bash.exe & powershell.exe.

Looking at task manager, cmd.exe shortcuts launches a console host / cmd.exe pair in an independent process.

wt.exe looks like it spawns children for each launch?

FYI: I just tried changing the icon on another app (robomongo.exe) and it displays different behavior than the cmd shell apps. It will use the new shortcut icon but any later invocations with other shortcuts will keep the icon of the original invocation shortcut.

brucejo75 avatar Mar 02 '20 15:03 brucejo75

Also I know this feature is used extensively by Microsoft and the industry. It is a way to have an icon for a shell script invocation.

brucejo75 avatar Mar 02 '20 15:03 brucejo75

I mean, this is a bug in the sense that setting an icon for wt.exe doesn't apply to WT windows in the same way it does for conhost windows.

My theory is really specific to app execution aliases - the platform does all sorts of weird things for "centennial" (packaged Win32 applications), and this might even be something they're tracking internally.

zadjii-msft avatar Mar 02 '20 15:03 zadjii-msft

ah, got it... I misunderstood. I will edit my comments...

brucejo75 avatar Mar 02 '20 15:03 brucejo75

Also, conhost has a heck lot of code written to make this work. The path to the lnk that spawned it is passed in STARTUPINFO, and conhost goes and cracks the link and does a resource load on the link's icon specifier.

It's doable, it's just a lot of annoying gross Win32 work.

DHowett-MSFT avatar Mar 02 '20 19:03 DHowett-MSFT

This is a feature-sized fix, so I've triaged it into the backlog. If somebody wants to look at it, and we know it actually works with app execution alias invocation (it might not!), we'd entertain it.

DHowett-MSFT avatar Mar 06 '20 00:03 DHowett-MSFT

@DHowett-MSFT, any chance this will be addressed? Thanks!

brucejo75 avatar Jul 10 '20 20:07 brucejo75

Also, conhost has a heck lot of code written to make this work. The path to the lnk that spawned it is passed in STARTUPINFO, and conhost goes and cracks the link and does a resource load on the link's icon specifier.

We could work-around this if there were a command-line option to set the icon. Perhaps that would be easier to implement?

dc46and2 avatar Jan 31 '23 21:01 dc46and2

Is this still in the works?

gloatoriginal avatar Apr 23 '23 10:04 gloatoriginal

Is it still in the works

I mean, no one's really taken a crack at it yet, so it's definitely still in the "ideation" phase.

https://github.com/microsoft/terminal/issues/1871#issuecomment-886754983 has some ideas on plumbing the tab's icon up as a "badge" on the Terminal's taskbar icon.

I think there's maybe an overarching "I don't want different Terminal windows to glom together on the taskbar" request that's a part of this, and that I'm not sure we can do easily. I dunno if different windows with different badges will de-glom. There's some thoughts in #8216, but I'm not gonna try and mix and match this thread with that one.

a now deprecated proposal

Maybe there's room for making the setting for "taskbarBadges" an enum like:

"taskbarIcon": "default" | "badge" | "replace" | <path>

or similar.

As a more comprehensive summarization:

  • #7076
    • "I want to straight up entirely replace the Terminal's icon, with a static image"
    • This makes me think that taskbarIcon would be a theme.window property, so that you could have different light & dark theme icons.
    • ❌ This seems impossible - I'm not sure packaged apps can change their icon at runtime.
  • #1871
    • "I want terminal's icon to display a badge for the current tab's icon"
    • ✅ This is very doable
  • #6556
    • "I want terminal's icon to be replaced by whatever the current tab's icon is"
    • ❌ This seems impossible
  • #14372
    • "I want the tab's icon to come from the console application that was launched" (read: from the shortcut to the application)
    • ✅ This is very doable
    • ❔ How do we expose this as a setting?
  • #4768 (This thread)
    • "I want the Terminal's icon to come from the shortcut to the Terminal itself"
    • ❌ This seems impossible - I'm not sure packaged apps can change their icon at runtime.
    • But we could plumb the icon from the shortcut up to the tab, which could be combined with the badge.
  • #705
    • "I want to use the icon from the commandline exe itself"
    • We could probably leverage a variation on this to do #14372. Just need to make sure it works with
      • defterm handoff
      • LNKs for shortcuts

You know, after re-reading all this, I'm thinking that (#6556 + #14372) is a better solution for "I want to have a shortcut to a CLI application with a custom icon, and have the Terminal open with that icon"


dev/migrie/f/4768-taskbar-icons has a WIP prototype. It can:

  • Set the taskbar overlay
  • Change the taskbar glomming, based on a runtime AUMID
  • Set the icon on the HWND, but NOT on the taskbar itself.

settings proposal 2

globals.showTaskbarOverlay: bool,
globals.taskbarGlomBehavior: "default"|"window"|"profile",

Also related:

  • #8216
    • I want different taskbar icons for {each window, each profile}.

zadjii-msft avatar Apr 28 '23 16:04 zadjii-msft

I was able to change the taskbar icon for terminal using these instructions, but it doesn't solve the issue of different icons for different profiles. Seems a bit hacky as well, may not be a feature to rely on. Maybe this has already been covered, but looks like the taskbar uses the appx id of the app to glom icons. If there was a way to duplicate/alias appx ids, that combined with the above would be a workaround for me, but not sure that's possible. (create a 'wsl' id and a 'ps' id that both point at the store-managed wt id and setup shortcuts that use those appropriately.) If you only had two profiles to switch between, you could use the 'preview' and 'release' builds from the store, heh.

stobor827 avatar Jul 04 '23 19:07 stobor827

I think this is gonna probably come down to #1871 + #8216 after all the discussions with the taskbar folks. Full up replacing our taskbar icon seems like a non-starter.

  • #8216 to allow taskbar entries to glom based on the profile of the currently active pane (which will probably be wacky for people constantly switching profiles, but for people with a single profile in a single pane in a single tab, it should be fine)
  • #1871 to get the profile's icon as an overlay on the taskbar.

Together, you could have different windows for different profiles, they wouldn't glom together, and they'd each have an overlay to indicate which profile they're running.

zadjii-msft avatar Aug 17 '23 13:08 zadjii-msft

It is incomplete, and I haven't check how it does it, but winget-cli already changes the icon of the tab inside terminal when retrieving the list, and also show a progress bar on the taskbar icon.

sebbu2 avatar Aug 15 '24 22:08 sebbu2