microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
94.88k stars 8.22k forks source link

Enable `globalSummon` / `quakeMode` to work even when there isn't a running Terminal #9996

Open zadjii-msft opened 3 years ago

zadjii-msft commented 3 years ago

This is probably going to need the "headless monarch" work we theorized. Different parts to this:

I've had many more thoughts on the matter in the past, I just need to have somewhere to put them.

MolotovCherry commented 10 months ago

@unennhexium Your task works fine for me verbatim (except I changed the user path to mine).

MadameMinty commented 8 months ago

In Start Menu\Programs\StartUp, I put a shortcut to wt.exe -w _quake with the dropdown Run set to Minimized. Upon startup, WT flickers once, then Quake Mode shortcut key works to show/hide the terminal until I alt+F4 or otherwise shutdown the process. It's not perfect, but close enough.

fleps commented 6 months ago

I can't believe we still don't have a WT argument --minimized yet.

The solutions proposed here do not work flawlessly, one (big) caveat for me was losing the ability to open your default profile Elevated / as administrator, even if configured on WT.

My workaround to have it as ADMIN was similar to above:

Still, can we PLEASE get a --minimized considering we already have --maximized???

GeorgeGedox commented 6 months ago

Could we know what is stopping the devs from implementing a proper option to start windows terminal in the background on startup if we want this? I'd like to be able to have quake mode available without using weird startup hacks or having a terminal instance active at all times in my taskbar, that defeats the purpose of quake mode.

The whole idea behind quake mode is to have a hotkey that opens the terminal at any time from anywhere without any previous intervention to "prep" it beforehand.

zadjii-msft commented 3 months ago

Could we know what is stopping the devs from implementing a proper option to start windows terminal in the background on startup if we want this?

Time, basically. I haven't had the chance to loop back around on --headless (as mentioned in https://github.com/microsoft/terminal/issues/9996#issuecomment-1452670063), or the "headless" startup task (as referenced in https://github.com/microsoft/terminal/issues/9996#issuecomment-1561249825 and further spec'd in https://github.com/microsoft/terminal/issues/13630#issuecomment-1452590629).

Not sure when exactly I'll have a chance to. I don't think these would be terribly difficult if someone in the community wanted to contribute either here. I could definitely provide guidance and pointers if someone runs into any questions.

MaverickMartyn commented 3 months ago

I can't believe we still don't have a WT argument --minimized yet.

The solutions proposed here do not work flawlessly, one (big) caveat for me was losing the ability to open your default profile Elevated / as administrator, even if configured on WT.

My workaround to have it as ADMIN was similar to above:

  • Go to your startup folder (run shell:startup)
  • Create a shortcut and on Target add wt pwsh -window minimized (I don't use quake mode, I have my Win+` set to globalSummon, you can add/keep the quake parameters if wanted)

    • In this case, make sure on your WT Settings > Appearance you have the option to hide the terminal to tray area when minimized
  • Set "Run" option also to Minimized (this prevents any flicker)
  • Click on Advanced button and check "Run as Administrator" (don't use the similar option from Compatibility tab, it's not the same, you want the one from the Advanced button)
  • Apply, OK.

Still, can we PLEASE get a --minimized considering we already have --maximized???

In regards to running as admin, I use PowerToys' Keyboard Manager to run terminal on CTRL+ALT+T, and CTRL+SHIFT+ALT+T runs it as administrator. Assuming you can make WT start in quake mode with a parameter, that should work too.

only-su commented 2 months ago

I can't believe we still don't have a WT argument --minimized yet. The solutions proposed here do not work flawlessly, one (big) caveat for me was losing the ability to open your default profile Elevated / as administrator, even if configured on WT. My workaround to have it as ADMIN was similar to above:

  • Go to your startup folder (run shell:startup)
  • Create a shortcut and on Target add wt pwsh -window minimized (I don't use quake mode, I have my Win+` set to globalSummon, you can add/keep the quake parameters if wanted)

    • In this case, make sure on your WT Settings > Appearance you have the option to hide the terminal to tray area when minimized
  • Set "Run" option also to Minimized (this prevents any flicker)
  • Click on Advanced button and check "Run as Administrator" (don't use the similar option from Compatibility tab, it's not the same, you want the one from the Advanced button)
  • Apply, OK.

Still, can we PLEASE get a --minimized considering we already have --maximized???

In regards to running as admin, I use PowerToys' Keyboard Manager to run terminal on CTRL+ALT+T, and CTRL+SHIFT+ALT+T runs it as administrator. Assuming you can make WT start in quake mode with a parameter, that should work too.

When using powertoys Keyboard Manager to run terminal is there a way to make it not open a new tab when a window already exists? In other way to make the command create a window when none exists or just invoke the existing tab instead of opening a new one whe it does?

Memoraike commented 2 months ago

When using powertoys Keyboard Manager to run terminal is there a way to make it not open a new tab when a window already exists? In other way to make the command create a window when none exists or just invoke the existing tab instead of opening a new one whe it does?

For your purpose, autohotkey will work. It doesn't work perfectly with minimized terminal windows, but as a temporary solution it's great. Don't forget to change keyboard shortcuts if necessary.

#Requires AutoHotkey v2.0
#SingleInstance

DetectHiddenWindows true
terminalName := "WindowsTerminal.exe"

; [Win Shift Enter] If the terminal is already open, activate it. Otherwise, open it.
#+Enter:: {
    if (pid := ProcessExist(terminalName)) {
        if WinExist("ahk_pid" pid) {
            PostMessage 0x0112, 0xF120, , , WinGetID("ahk_pid" pid)
            WinActivate
        }
    } else {
        Run("wt")
    }
}

; [Win Enter] Open the terminal in a new window.
#Enter:: {
    Run("wt")
}

; [Win `] Open the terminal in a quake mode. Only works if the terminal is not already open. Require setting same hotkey in the terminal.
#HotIf !ProcessExist(terminalName)
#`:: {
    Run("wt -w _quake")
}

To work correctly with minimized windows, you should enable this option in the settings:

![image](https://github.com/microsoft/terminal/assets/46358138/0337456b-0c37-4d21-adb4-0f802a4763d2)
MaverickMartyn commented 2 months ago

For anyone on Windows 11, you can start a new Terminal using WIN+X, followed by I for Terminal or A for elevated Terminal.
It's not perfect, but it works without any 3rd party software or setup.