terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Add command-line option start terminal minimized

Open jarpoole opened this issue 5 years ago • 38 comments
trafficstars

Description of the new feature/enhancement

Currently command-line options for launching the windows terminal in maximized and full screen modes are available (-M and -F respectively). Notably, an option of launching minimized is missing.

I use windows task scheduler to start a variety of scripts at logon to insure my build environment is brought up to date the second I logon. Having the output of these scripts display in an interactive terminal is extremely helpful. However when I start my computer and I am not quite ready to work I must interact with the windows terminal to minimize it. A minimize flag in the command line options would solve this issue.

jarpoole avatar Aug 23 '20 02:08 jarpoole

I thought START /MIN wt.exe could be used as a workaround, but it leads to the crash https://github.com/microsoft/terminal/issues/7396.

KalleOlaviNiemitalo avatar Aug 25 '20 13:08 KalleOlaviNiemitalo

@zadjii-msft, @KalleOlaviNiemitalo, @jarpoole - does the behavior where the terminal is open and then is immediately minimized work for you?

I have a PoC for something like this and wondering if I should productize it or abandon :smile: OpenMinimized

Don-Vito avatar Nov 02 '20 14:11 Don-Vito

@Don-Vito, how do you "immediately" minimize it? When I first quit Windows Terminal Preview 1.4.2652.0 and then repeatedly click the button that I have pinned to the task bar, the window doesn't lose its title bar.

There is the toggleFocusMode action though, if you don't want a title bar.

KalleOlaviNiemitalo avatar Nov 02 '20 17:11 KalleOlaviNiemitalo

Or did you mean you have modified Windows Terminal to add a feature that minimizes the window immediately after opening?

KalleOlaviNiemitalo avatar Nov 02 '20 17:11 KalleOlaviNiemitalo

@KalleOlaviNiemitalo - yes, I wrote a proof of concept solution that allows you to run "wt -m" or "wt --minimized" or "wt --minimized --focused" (what you actually see in the gif above).

However to implement this, I first allow the window to render fully with default dimensions and only then send a "minimize" signal (very similar to how full screen is implemented).

First I tried to implement this by starting with a minimized window, but then restoring to the default size created it with the wrong dimensions, so I fallbacked to this solution.

There is not much code there - here is the PR: https://github.com/Don-Vito/terminal/pull/3.

My question is whether this satisfies your need and worth trying to push this upstream.

Don-Vito avatar Nov 02 '20 18:11 Don-Vito

@zadjii-msft - do you want me to productize it as is (screen is open on startup and then is immediately minimized)?

Don-Vito avatar Nov 03 '20 14:11 Don-Vito

I guess when I'm imagining this, the window doesn't even flash on the screen. I could see there being difficulties with that though - is there any way for us to like, cache what the initial launch size should be, and immediately resize the window to that size when it's first restored from launching minimized?

I guess if there's not, then this is a good enough solution to start with, and we could always leave the door open for the possibility of figuring it out in the future.

zadjii-msft avatar Nov 03 '20 14:11 zadjii-msft

@zadjii-msft - you are absolutely correct that this should be the approach - compute the desired size, cache it and start minimized. I am sure we can make it working, but still don't know how :smile:. The question is whether we want to push the silly solution I did, as sort of a temporary solution, until we solve it correctly.

Don-Vito avatar Nov 03 '20 20:11 Don-Vito

Another hack could be to make the window initially normal-size but hidden (SW_HIDE), then minimize it after it has been initialized. However, I don't know how feasible that is with the UI libraries that Windows Terminal is using; and if there were a problem during initialization, then the window might remain hidden and the user would not know that the process still exists.

KalleOlaviNiemitalo avatar Nov 04 '20 08:11 KalleOlaviNiemitalo

Any update on this? Would love to see it

OneYellowLemon avatar Nov 30 '21 22:11 OneYellowLemon

Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button? image That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️

zadjii-msft avatar Nov 30 '21 23:11 zadjii-msft

Hi, maybe you can extend the issue. Currently if you only want have the quake window on standby after bootup (wt -w _quacke) the pane stayes open. Not ideal in the boot process… and no, "start /min wt…" is not the solution, because it results in a funny sized quacke pane.

with an parameter -min or what ever you can keep the pane open as default…

Cheers

toraxmalu avatar Jan 14 '22 06:01 toraxmalu

Note to self: For the minimized start mode, we might be able to use the DWM Cloaked thing to hide the window entirely when it's first being started up. That would let us create the window with a real size and position, and then minimize it, then uncloak it so that it can be restored to the correct size, already initialized.

zadjii-msft avatar Apr 11 '22 19:04 zadjii-msft

I use the quake mode a lot (via hotkey), but the quake hotkey doesn't work unless the terminal is already running - so I always have to start the terminal first before being able to quake it, which is really annoying.

Having the terminal launching minimized upon machine startup solves this issue.

radutomy avatar Oct 12 '22 12:10 radutomy

I use the quake mode a lot (via hotkey), but the quake hotkey doesn't work unless the terminal is already running - so I always have to start the terminal first before being able to quake it, which is really annoying.

Having the terminal launching minimized upon machine startup solves this issue.

Would like to second that.

We would like to use quake mode as our daily runner, with the zsh available on demand via hotkey, not having to start the terminal application.

Best option would be, in my honest opinion:

  1. Add parameter "--ready-to-quake" or something that starts the terminal as background process
  2. Only on hotkey toggle quake
  3. Never end the quake-terminal-process on exit, but restart shell instead (with hiding for the time being)
  4. Still allow additional terminal windows

symphonic-navigator avatar Nov 20 '22 16:11 symphonic-navigator

I'm getting pushed away from using quake mode thanks to not being able to start it minimized, thanks

EDIT: I found out I can run a shortcut (.lnk) from task scheduler, now I have it auto start with windows and it's minimized.

brunoherrera avatar Jan 21 '23 19:01 brunoherrera

EDIT: I found out I can run a shortcut (.lnk) from task scheduler, now I have it auto start with windows and it's minimized.

What is the shortcut/parameters, you are launching

nirgranth avatar Jan 22 '23 15:01 nirgranth

EDIT: I found out I can run a shortcut (.lnk) from task scheduler, now I have it auto start with windows and it's minimized.

What is the shortcut/parameters, you are launching

create a new link with to target wt.exe (I have windows terminal installed from microsoft store): %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe

once you created it, right click, properties, where it says Run select Minimized from the dropdown list

then in task manager, actions:

start a program: cmd.exe

then in Add arguments/parameters you add /c and the path to the link, mine looks like this: /C "%userprofile%\Dropbox\PC\Documents\My Shortcuts\Windows Terminal.lnk"

triggers: at log on of any user

and I checked the box "run with highest privileges", so I can have quake mode as admin

my settings for windows terminal: launch on machine startup DISABLED hide terminal in the notification area when it is minimized ENABLED actions>add new>show/hide wuake window ctrl + alt + shift + T

if I ever want to have a non admin terminal I just have windows terminal to taskbar anyways, for whatever else I use quake terminal

brunoherrera avatar Jan 22 '23 15:01 brunoherrera

EDIT: I found out I can run a shortcut (.lnk) from task scheduler, now I have it auto start with windows and it's minimized.

What is the shortcut/parameters, you are launching

create a new link with to target wt.exe (I have windows terminal installed from microsoft store): %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe

once you created it, right click, properties, where it says Run select Minimized from the dropdown list

then in task manager, actions:

start a program: cmd.exe

then in Add arguments/parameters you add /c and the path to the link, mine looks like this: /C "%userprofile%\Dropbox\PC\Documents\My Shortcuts\Windows Terminal.lnk"

triggers: at log on of any user

and I checked the box "run with highest privileges", so I can have quake mode as admin

my settings for windows terminal: launch on machine startup DISABLED hide terminal in the notification area when it is minimized ENABLED actions>add new>show/hide wuake window ctrl + alt + shift + T

if I ever want to have a non admin terminal I just have windows terminal to taskbar anyways, for whatever else I use quake terminal

Unfortunately on my system, this doesn't work. I try an launch the shortcut and it causes an error to occur when launching PWSH. For some reason it works fine when I disable the start minimised in the shortcut. Is this some sort of bug?

PixelQubed avatar Jan 22 '23 16:01 PixelQubed

Is this some sort of bug?

no idea, haven't had any issues

brunoherrera avatar Jan 22 '23 16:01 brunoherrera

Is this some sort of bug?

no idea, haven't had any issues

I get this error. [error 2147942487 (0x80070057) when launching "C:\Users\synta\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe"']

PixelQubed avatar Jan 22 '23 16:01 PixelQubed

Ah, ok, I figured it out. Just to let you know, you REQUIRE elevated access when launching PowerShell in this manner. Weird... It could be a security thing to stop consoles from just appearing minimised to prevent bad actors from using them in secret.

PixelQubed avatar Jan 22 '23 16:01 PixelQubed

Ah, ok, I figured it out. Just to let you know, you REQUIRE elevated access when launching PowerShell in this manner. Weird... It could be a security thing to stop consoles from just appearing minimised to prevent bad actors from using them in secret.

you forgot to click "run with highest privileges" checkbox in task scheduler?

brunoherrera avatar Jan 22 '23 16:01 brunoherrera

Ah, ok, I figured it out. Just to let you know, you REQUIRE elevated access when launching PowerShell in this manner. Weird... It could be a security thing to stop consoles from just appearing minimised to prevent bad actors from using them in secret.

you forgot to click "run with highest privileges" checkbox in task scheduler?

I didn't want to launch it elevated by default since I'm pretty security conscious. Unfortunately, there is no other way I can find to not have to elevate its perms. This really needs to be a built-in feature to prevent stuff like this from occurring. I feel like that way, the terminal will become more integrated with the system.

PixelQubed avatar Jan 22 '23 16:01 PixelQubed

I didn't want to launch it elevated by default since I'm pretty security conscious. Unfortunately, there is no other way I can find to not have to elevate its perms. This really needs to be a built-in feature to prevent stuff like this from occurring. I feel like that way, the terminal will become more integrated with the system.

yeah it's just weird why they have Maximized, Full Screen, Focus and Miximized focus, but not Minimized as Launch modes for startup for almost 2 years and a half....

brunoherrera avatar Jan 22 '23 16:01 brunoherrera

yeah it's just weird why they have Maximized, Full Screen, Focus and Miximized focus, but not Minimized

I mean, higher up in the thread pretty much explains why --minimized is Hard relative to the others. (comments starting here: https://github.com/microsoft/terminal/issues/7374#issuecomment-720651150)

We might be able to do --minimized based off the work in #13811. That PR will make it so we don't ShowWindow(SW_SHOW) until the window has figured out its size and position. Building off that, we could use --minimized to show the window as minimized immediately. That would probably work, but someone (theoretically me) has to figure out the last edge cases in that PR first. I'd love the help though! If someone wants to come through and help get that PR across the finish line, I'd appreciate the help ☺️

zadjii-msft avatar Jan 23 '23 12:01 zadjii-msft

someone (theoretically me) has to figure out the last edge cases in that PR first. I'd love the help though! If someone wants to come through and help get that PR across the finish line, I'd appreciate the help ☺️

I can help you can ping me if needed

nirgranth avatar Jan 23 '23 16:01 nirgranth

I've left notes in https://github.com/microsoft/terminal/pull/13811#issuecomment-1402043630 😉

zadjii-msft avatar Jan 24 '23 14:01 zadjii-msft

Is there a way to start the terminal in focus mode only for a batch file?

Silther avatar Jan 27 '23 14:01 Silther

EDIT: I found out I can run a shortcut (.lnk) from task scheduler, now I have it auto start with windows and it's minimized.

What is the shortcut/parameters, you are launching

create a new link with to target wt.exe (I have windows terminal installed from microsoft store): %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe

once you created it, right click, properties, where it says Run select Minimized from the dropdown list

then in task manager, actions:

start a program: cmd.exe

then in Add arguments/parameters you add /c and the path to the link, mine looks like this: /C "%userprofile%\Dropbox\PC\Documents\My Shortcuts\Windows Terminal.lnk"

triggers: at log on of any user

and I checked the box "run with highest privileges", so I can have quake mode as admin

my settings for windows terminal: launch on machine startup DISABLED hide terminal in the notification area when it is minimized ENABLED actions>add new>show/hide wuake window ctrl + alt + shift + T

if I ever want to have a non admin terminal I just have windows terminal to taskbar anyways, for whatever else I use quake terminal

Thanks for the solution; just a minor correction:

"...then in task ~~manager~~Task Scheduler, actions:"

mmarkus13 avatar Jan 27 '23 19:01 mmarkus13