flyingpie / windows-terminal-quake

Turn any app into a Quake-style toggleable app.
https://wtq.flyingpie.nl
MIT License
547 stars 35 forks source link

Support terminals other than windows terminal #83

Closed untoreh closed 1 month ago

flyingpie commented 3 years ago

@untoreh Thank you for opening the issue.

For administrative purposes, this is about support for other terminals in general, specifically Wez's Terminal Emulator.

flyingpie commented 3 years ago

@untoreh First build with support for this feature is available:

https://github.com/flyingpie/windows-terminal-quake/releases/tag/v1.3

To make this work with other terminals, 2 settings need to be changed. I'm using the following setup:

{
    "$schema": "./windows-terminal-quake.schema.1.json",

    "Hotkeys": [
        { "Modifiers": "Control", "Key": "Oemtilde" },
        { "Modifiers": "Control", "Key": "Q" }
    ],

    // Just some general stuff
    "Notifications": false,
    "Opacity": 80,
    "ToggleDurationMs": 150,
    "ToggleAnimationType": "EaseOutQuart",
    "VerticalScreenCoverage": 95,
    "HorizontalAlign": "Center",
    "HorizontalScreenCoverage": 100,
    "HideOnFocusLost": false,
    "PreferMonitor": "WithCursor",

    // "Move" works nicer for non-vertical monitor setups
    "ToggleMode": "Move",

    // These 2 settings are specific to this feature
    "ProcessProvider": "GenericProcessProvider",
    "WindowsTerminalCommand": "C:\\Downloads\\WezTerm-windows-20210502-154244-3f7122cb\\wezterm-gui.exe"
}
untoreh commented 3 years ago

Thank you!, it works fine, maybe you also want an option to pass arguments to the process, shortcuts don't work.

Also about the window buttons on top right there is only one small unaligned red X.

flyingpie commented 3 years ago

@untoreh I have to admit that I'm not too familiar with Wez's Terminal, so I did notice the little cross, but looked "normal" to me :)

Could you perhaps show me what the terminal should look like, and perhaps tell me how you launch it (without win-term-quake) and what your configs/keyboard shortcuts/etc. look like?

Arguments: You should be able to pass command line arguments to windows-terminal-quake, and they should be passed on to the actual terminal.

Shortcuts: What kind of shortcuts do you mean?

Thanks in advance, these comments are really helpful in making this little app more useful.

untoreh commented 3 years ago

For shortcuts I just meant windows .lnk files which you can add arguments to. Since as you mentioned windoes-terminal-quake forwards arguments to the terminal, this is not an issue anymore and anyway I can also configure default startup options from the terminal side.

For The X button I don't do anything out of the ordinary when I launch manually, and the window has proper top right buttons:

C:\Users\fra\scoop\apps\wezterm\current\wezterm-gui.exe start wsl.exe

However since this is a dropdown terminal, I can just disable window decorations from wezterm with:

return {
window_decorations = "NONE"
}
flyingpie commented 3 years ago

@untoreh Would it be possible to attach a set of config files or something so I can run pretty much the same thing you're running?

untoreh commented 3 years ago

.wezterm.lua

local wezterm = require 'wezterm';
local launch_menu = {}

if wezterm.target_triple == "x86_64-pc-windows-msvc" then
  table.insert(launch_menu, {
                 label = "PowerShell",
                 args = {"powershell.exe", "-NoLogo"},
  })
end

return {
  window_decorations = "NONE",
  font = wezterm.font("Hack"),
  color_scheme = "Dracula",
  scrollback_lines = 9000,
  enable_scroll_bar = true,
  launch_menu = launch_menu,
  default_prog =  {"wsl.exe", "-e", "bash", "-li"},
  keys = {
    {key="|", mods="CTRL|SHIFT", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
    {key="q", mods="CTRL|SHIFT",
     action=wezterm.action{CloseCurrentPane={confirm=true}}},
    {key="_", mods="CTRL|SHIFT", action=wezterm.action{SplitVertical={domain="CurrentPaneDomain"}}},
    {key="h", mods="CTRL|SHIFT", action=wezterm.action{ActivatePaneDirection="Left"}},
    {key="j", mods="CTRL|SHIFT", action=wezterm.action{ActivatePaneDirection="Down"}},
    {key="k", mods="CTRL|SHIFT", action=wezterm.action{ActivatePaneDirection="Up"}},
    {key="l", mods="CTRL|SHIFT", action=wezterm.action{ActivatePaneDirection="Right"}},
    {key="h", mods="CTRL|SHIFT|ALT", action=wezterm.action{AdjustPaneSize={"Left", 1}}},
    {key="j", mods="CTRL|SHIFT|ALT", action=wezterm.action{AdjustPaneSize={"Down", 1}}},
    {key="k", mods="CTRL|SHIFT|ALT", action=wezterm.action{AdjustPaneSize={"Up", 1}}},
    {key="l", mods="CTRL|SHIFT|ALT", action=wezterm.action{AdjustPaneSize={"Right", 1}}} ,
    {key="{", mods="SHIFT|ALT", action=wezterm.action{ActivateTabRelative=-1}},
    {key="}", mods="SHIFT|ALT", action=wezterm.action{ActivateTabRelative=1}},
    {key="p", mods="SHIFT|ALT", action=wezterm.action{ScrollToPrompt=-1}},
    {key="n", mods="SHIFT|ALT", action=wezterm.action{ScrollToPrompt=1}},
    {key="u", mods="CTRL|SHIFT", action=wezterm.action{ScrollByPage=-1}},
    {key="d", mods="CTRL|SHIFT", action=wezterm.action{ScrollByPage=1}},
    {key="j", mods="SHIFT|ALT", action=wezterm.action{ScrollByLine=1}},
    {key="k", mods="SHIFT|ALT", action=wezterm.action{ScrollByLine=-1}},
    {key="l", mods="SHIFT|ALT", action="ShowLauncher"},
    {key="a", mods="CTRL|SHIFT", action=wezterm.action{
       SpawnCommandInNewTab={
         args={"wsl.exe", "-d", "Arch", "-e", "bash", "-li"}}}},
    {key="p", mods="CTRL|SHIFT", action=wezterm.action{
       SpawnCommandInNewTab={
         args={"powershell.exe", "/NoLogo"}}}}

  },
}

windows-terminal-quake.json

{

    "$schema": "./windows-terminal-quake.schema.1.json",
    "WindowsTerminalCommand": "C:\\Users\\fra\\scoop\\apps\\wezterm\\current\\wezterm-gui.exe",
    "ProcessProvider": "GenericProcessProvider",
    // The keys that can be used to toggle the terminal.
    // See "HotKeys" bellow for possible values.
    "HotKeys": [
        {
            "Modifiers": "Windows",
            "Key": "OemTilde"
        }
    ],

    // Whether to show notifications when the app starts and when the settings are reloaded.
    "Notifications": false,

    // Make the window see-through (applies to the entire window, including the title bar).
    // 0 (invisible) - 100 (opaque)
    "Opacity": 99,

    // How long the toggle up/down takes in milliseconds.
    "ToggleDurationMs": 45,

    //"ToggleAnimationType": "EaseOutQuart",

    // How long each frame in the toggle animation takes in milliseconds.
    // The lower this value, the smoother the animation, though values lower than 15 are not supported.
    "ToggleAnimationFrameTimeMs": 15,

    // How much room to leave between the top of the terminal and the top of the screen.
    "VerticalOffset": 30,

    // How far the terminal should come down, in percentage (eg. 50 = half way, 100 = full screen).
    "VerticalScreenCoverage": 80,

    // When "HorizontalScreenCoverage" is below 100, this setting determines where the terminal is place horizontally.
    // "Center", "Left" or "Right".
    "HorizontalAlign": "Center",

    // How much horizontal space the terminal should use. When this is below 100, the terminal is centered.
    // This can also be above 100, which can be useful to compensate for the window not always taking a 100% of the screen width,
    // due to the terminal being bound to column widths (eg. try 100.5 or 101).
    "HorizontalScreenCoverage": 100,

    // When clicking or alt-tabbing away to another app, the terminal will automatically (and instantly) hide.
    "HideOnFocusLost": true,

    // Whether to keep the terminal window always on top (requires restart).
    "AlwaysOnTop": false,

    // Whether to hide the terminal window immediately after app start.
    "StartHidden": true,

    // What monitor to preferrably drop the terminal
    // "WithCursor" (default), "Primary" or "AtIndex"
    "PreferMonitor": "WithCursor",

    // If "PreferMonitor" is set to "AtIndex", this setting determines what monitor to choose.
    // Zero based, eg. 0, 1, etc.
    "MonitorIndex": 1,
    // "Move" works nicer for non-vertical monitor setups
    "ToggleMode": "Move",

    // # HotKeys
    // ## Modifiers
    // Alt, Control, Shift, Windows
    //
    // ## Key
    // ### Special keys
    // Alt, Back, CapsLock, Control, Escape, LControlKey, LShiftKey, LWin, RControlKey, RShiftKey, RWin, Shift, Space, Tab
    //
    // ### Middle part of the keyboard
    // Delete, End, Home, Insert, PageDown, PageUp, PrintScreen
    // Down, Left, Right, Up
    //
    // ### Number keys
    // D0 - D9
    //
    // ### Letters
    // A-Z
    //
    // ### Numpad
    // NumPad0 - NumPad9
    // Add, Decimal, Divide, Multiply, NumLock, Separator, Subtract
    //
    // ### Function keys
    // F1 - F24
    //
    // ### Special characters
    // OemBackslash, OemClear, OemCloseBrackets, Oemcomma, OemMinus, OemOpenBrackets,
    // OemPeriod, OemPipe, Oemplus, OemQuestion, OemQuotes, OemSemicolon, Oemtilde
    // Oem1 - Oem8, Oem102
}

edit: tried building myself from the generic process branch merged on master, the MainWindowHandle still gives problem

flyingpie commented 1 month ago

WTQ v2 now has support for terminals other than WT, and even applications that aren't terminals at all. Thank you for your feedback on this, it's been really useful!