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

Add startup task, setting to launch application on login #4908

Merged
30 commits merged into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
724d08f
Add uwp5 extensions, startup task to appx manifest
Mar 12, 2020
273956a
Add StartOnUserLogin setting to global settings
Mar 13, 2020
72a0bc1
Pull Windows.ApplicationModel into project. Add logic to control star…
Mar 13, 2020
6423c97
Change startup task display name in manifest to pull from res
Mar 13, 2020
35dcdb1
Add call to apply startup task setting on application load
Mar 13, 2020
9a84eac
Add settings schema entry for startOnUserLogin.
Mar 13, 2020
59e964c
Apply code formatting changes
Mar 13, 2020
db9d89c
Merge branch 'master' into dev/jelster/enable-onstartup
Mar 18, 2020
c282610
Merge branch 'master' into dev/jelster/enable-onstartup
Mar 20, 2020
99f7813
Merge branch 'master' of https://github.com/microsoft/terminal into d…
Mar 23, 2020
91669b9
Update json serialization usage pattern to use JsonUtils
Mar 23, 2020
4438c27
Merge branch 'master' into dev/jelster/enable-onstartup
Apr 8, 2020
99fc071
fix merge conflict shrapnel
Apr 8, 2020
6ca9137
Merge branch 'master' of https://github.com/microsoft/terminal into d…
Apr 9, 2020
e04de3f
Merge branch 'master' of https://github.com/microsoft/terminal into d…
Apr 15, 2020
52a6920
Merge branch 'master' of https://github.com/microsoft/terminal into d…
Apr 20, 2020
8d740b7
Merge branch 'master' of https://github.com/microsoft/terminal into d…
Apr 21, 2020
eb220fc
Update to latest pre-release
Apr 22, 2020
b0cb771
Merge branch 'master' of https://github.com/microsoft/terminal into d…
May 1, 2020
cae7c06
Merge branch 'master' of https://github.com/microsoft/terminal into d…
May 5, 2020
08284bd
Merge branch 'master' of https://github.com/microsoft/terminal into d…
May 13, 2020
50c01ea
Merge branch 'master' of https://github.com/microsoft/terminal into d…
May 14, 2020
07f3434
Merge branch 'master' of https://github.com/microsoft/terminal into d…
May 28, 2020
f30195a
Remove merge shrapnel
May 29, 2020
2ab2b47
Merge branch 'master' of https://github.com/microsoft/terminal into d…
May 29, 2020
884116c
add startup manifest info to preview
May 29, 2020
39c9feb
Add GH issue link, remove unneeded initialization (thanks @zadjii-msft!)
May 29, 2020
a783e45
Remove default case statement, merge shrapnel. Use weak ref in fire_a…
May 31, 2020
76936d9
Run code formatter to remove an extraneous whitespace at the end of a…
May 31, 2020
fc1a555
Use _root to get Dispatcher, stop trying to be fancy by returning early
May 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/cascadia/SettingsSchema.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Settings.json Documentation

## Globals

Properties listed below affect the entire window, regardless of the profile settings.

| Property | Necessity | Type | Default | Description |
Expand All @@ -21,11 +22,13 @@ Properties listed below affect the entire window, regardless of the profile sett
| `tabWidthMode` | Optional | String | `equal` | Sets the width of the tabs. Possible values: `"equal"`, `"titleLength"` |
| `wordDelimiters` | Optional | String | <code>&nbsp;&#x2f;&#x5c;&#x28;&#x29;&#x22;&#x27;&#x2d;&#x3a;&#x2c;&#x2e;&#x3b;&#x3c;&#x3e;&#x7e;&#x21;&#x40;&#x23;&#x24;&#x25;&#x5e;&#x26;&#x2a;&#x7c;&#x2b;&#x3d;&#x5b;&#x5d;&#x7b;&#x7d;&#x7e;&#x3f;│</code><br>_(`│` is `U+2502 BOX DRAWINGS LIGHT VERTICAL`)_ | Determines the delimiters used in a double click selection. |
| `confirmCloseAllTabs` | Optional | Boolean | `true` | When set to `true` closing a window with multiple tabs open WILL require confirmation. When set to `false` closing a window with multiple tabs open WILL NOT require confirmation. |
| `startOnUserLogin` | Optional | Boolean | `false` | When set to `true` enables the launch of Windows Terminal at startup. Setting to `false` will disable the startup task entry. Note: if the Windows Terminal startup task entry is disabled either by org policy or by user action this setting will have no effect. |
| `disabledProfileSources` | Optional | Array[String] | `[]` | Disables all the dynamic profile generators in this list, preventing them from adding their profiles to the list of profiles on startup. This array can contain any combination of `Windows.Terminal.Wsl`, `Windows.Terminal.Azure`, or `Windows.Terminal.PowershellCore`. For more information, see [UsingJsonSettings.md](https://github.com/microsoft/terminal/blob/master/doc/user-docs/UsingJsonSettings.md#dynamic-profiles) |
| `experimental.rendering.forceFullRepaint` | Optional | Boolean | `false` | When set to true, we will redraw the entire screen each frame. When set to false, we will render only the updates to the screen between frames. |
| `experimental.rendering.software` | Optional | Boolean | `false` | When set to true, we will use the software renderer (a.k.a. WARP) instead of the hardware one. |

## Profiles

Properties listed below are specific to each unique profile.

| Property | Necessity | Type | Default | Description |
Expand Down Expand Up @@ -64,6 +67,7 @@ Properties listed below are specific to each unique profile.
| `experimental.retroTerminalEffect` | Optional | Boolean | `false` | When set to `true`, enable retro terminal effects. This is an experimental feature, and its continued existence is not guaranteed. |

## Schemes

Properties listed below are specific to each color scheme. [ColorTool](https://github.com/microsoft/terminal/tree/master/src/tools/ColorTool) is a great tool you can use to create and explore new color schemes. All colors use hex color format.

| Property | Necessity | Type | Description |
Expand Down Expand Up @@ -91,6 +95,7 @@ Properties listed below are specific to each color scheme. [ColorTool](https://g
| `yellow` | _Required_ | String | Sets the color used as ANSI yellow. |

## Keybindings

Properties listed below are specific to each custom key binding.

| Property | Necessity | Type | Description |
Expand Down Expand Up @@ -146,6 +151,7 @@ For commands with arguments:
`ctrl+`, `shift+`, `alt+`

#### Keys

| Type | Keys |
| ---- | ---- |
| Function and Alphanumeric Keys | `f1-f24`, `a-z`, `0-9` |
Expand All @@ -155,6 +161,7 @@ For commands with arguments:
| Numpad Keys | `numpad_0-numpad_9`, `numpad0-numpad9`, `numpad_add`, `numpad_plus`, `numpad_decimal`, `numpad_period`, `numpad_divide`, `numpad_minus`, `numpad_subtract`, `numpad_multiply` |

## Background Images and Icons

Some Terminal settings allow you to specify custom background images and icons. It is recommended that custom images and icons are stored in system-provided folders and are referred to using the correct [URI Schemes](https://docs.microsoft.com/en-us/windows/uwp/app-resources/uri-schemes). URI Schemes provide a way to reference files independent of their physical paths (which may change in the future).

The most useful URI schemes to remember when customizing background images and icons are:
Expand All @@ -167,6 +174,7 @@ The most useful URI schemes to remember when customizing background images and i
> ⚠ Note: Do not rely on file references using the `ms-appx` URI Scheme (i.e. icons). These files are considered an internal implementation detail and may change name/location or may be omitted in the future.

### Icons

Terminal displays icons for each of your profiles which Terminal generates for any built-in shells - PowerShell Core, PowerShell, and any installed Linux/WSL distros. Each profile refers to a stock icon via the `ms-appx` URI Scheme.

> ⚠ Note: Do not rely on the files referenced by the `ms-appx` URI Scheme - they are considered an internal implementation detail and may change name/location or may be omitted in the future.
Expand All @@ -180,6 +188,7 @@ You can refer to you own icons if you wish, e.g.:
> 👉 Tip: Icons should be sized to 32x32px in an appropriate raster image format (e.g. .PNG, .GIF, or .ICO) to avoid having to scale your icons during runtime (causing a noticeable delay and loss of quality.)

### Custom Background Images

You can apply a background image to each of your profiles, allowing you to configure/brand/style each of your profiles independently from one another if you wish.

To do so, specify your preferred `backgroundImage`, position it using `backgroundImageAlignment`, set its opacity with `backgroundImageOpacity`, and/or specify how your image fill the available space using `backgroundImageStretchMode`.
Expand Down
7 changes: 7 additions & 0 deletions src/cascadia/CascadiaPackage/Package-Dev.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
xmlns:desktop5="http://schemas.microsoft.com/appx/manifest/desktop/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
IgnorableNamespaces="uap mp rescap">

<Identity
Expand Down Expand Up @@ -62,6 +63,12 @@
<desktop:ExecutionAlias Alias="wtd.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>
<uap5:Extension Category="windows.startupTask">
<uap5:StartupTask
TaskId="StartTerminalOnLoginTask"
Enabled="false"
DisplayName="ms-resource:AppNameDev" />
</uap5:Extension>

<com:Extension Category="windows.comServer">
<com:ComServer>
Expand Down
8 changes: 7 additions & 1 deletion src/cascadia/CascadiaPackage/Package-Pre.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:uap7="http://schemas.microsoft.com/appx/manifest/uap/windows10/7"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
Expand Down Expand Up @@ -63,7 +64,12 @@
<desktop:ExecutionAlias Alias="wt.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>

<uap5:Extension Category="windows.startupTask">
<uap5:StartupTask
TaskId="StartTerminalOnLoginTask"
Enabled="false"
DisplayName="ms-resource:AppNamePre" />
</uap5:Extension>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="WindowsTerminalShellExt">
Expand Down
7 changes: 7 additions & 0 deletions src/cascadia/CascadiaPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:uap7="http://schemas.microsoft.com/appx/manifest/uap/windows10/7"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
Expand Down Expand Up @@ -63,6 +64,12 @@
<desktop:ExecutionAlias Alias="wt.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>
<uap5:Extension Category="windows.startupTask">
<uap5:StartupTask
TaskId="StartTerminalOnLoginTask"
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
Enabled="false"
DisplayName="ms-resource:AppName" />
</uap5:Extension>

<com:Extension Category="windows.comServer">
<com:ComServer>
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalApp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "App.g.cpp"

using namespace winrt;
using namespace winrt::Windows::ApplicationModel;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::UI::Xaml;
Expand Down
41 changes: 41 additions & 0 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <LibraryResources.h>

using namespace winrt::Windows::ApplicationModel;
using namespace winrt::Windows::ApplicationModel::DataTransfer;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Core;
Expand All @@ -23,6 +24,7 @@ namespace winrt
using IInspectable = Windows::Foundation::IInspectable;
}

static const winrt::hstring StartupTaskName = L"StartTerminalOnLoginTask";
// clang-format off
// !!! IMPORTANT !!!
// Make sure that these keys are in the same order as the
Expand Down Expand Up @@ -243,6 +245,7 @@ namespace winrt::TerminalApp::implementation
_root->Create();

_ApplyTheme(_settings->GlobalSettings().GetTheme());
_ApplyStartupTaskStateChange();

TraceLoggingWrite(
g_hTerminalAppProvider,
Expand Down Expand Up @@ -755,6 +758,43 @@ namespace winrt::TerminalApp::implementation
_ApplyTheme(_settings->GlobalSettings().GetTheme());
}

fire_and_forget AppLogic::_ApplyStartupTaskStateChange()
{
auto weakThis{ get_weak() };
co_await winrt::resume_foreground(_root->Dispatcher(), CoreDispatcherPriority::Normal);
if (auto page{ weakThis.get() })
{
StartupTaskState state;
bool tryEnableStartupTask = _settings->GlobalSettings().StartOnUserLogin();
StartupTask task = co_await StartupTask::GetAsync(StartupTaskName);

state = task.State();
switch (state)
{
case StartupTaskState::Disabled:
{
if (tryEnableStartupTask)
{
co_await task.RequestEnableAsync();
}
break;
}
case StartupTaskState::DisabledByUser:
{
// TODO: GH#6254: define UX for other StartupTaskStates
break;
}
case StartupTaskState::Enabled:
{
if (!tryEnableStartupTask)
{
task.Disable();
}
break;
}
}
}
}
// Method Description:
// - Reloads the settings from the profile.json.
void AppLogic::_ReloadSettings()
Expand Down Expand Up @@ -783,6 +823,7 @@ namespace winrt::TerminalApp::implementation
_root->SetSettings(_settings, true);

_RefreshThemeRoutine();
_ApplyStartupTaskStateChange();
}

// Method Description:
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/AppLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace winrt::TerminalApp::implementation
fire_and_forget _LoadErrorsDialogRoutine();
fire_and_forget _ShowLoadWarningsDialogRoutine();
fire_and_forget _RefreshThemeRoutine();
fire_and_forget _ApplyStartupTaskStateChange();

void _OnLoaded(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);

Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalApp/GlobalAppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static constexpr std::wstring_view FullscreenLaunchModeValue{ L"fullscreen" };
static constexpr std::wstring_view LightThemeValue{ L"light" };
static constexpr std::wstring_view DarkThemeValue{ L"dark" };
static constexpr std::wstring_view SystemThemeValue{ L"system" };
static constexpr std::string_view EnableStartupTaskKey{ "startOnUserLogin" };

static constexpr std::string_view ForceFullRepaintRenderingKey{ "experimental.rendering.forceFullRepaint" };
static constexpr std::string_view SoftwareRenderingKey{ "experimental.rendering.software" };
Expand Down Expand Up @@ -342,6 +343,8 @@ void GlobalAppSettings::LayerJson(const Json::Value& json)

// GetBool will only override the current value if the key exists
JsonUtils::GetBool(json, DebugFeaturesKey, _debugFeatures);

JsonUtils::GetBool(json, EnableStartupTaskKey, _StartOnUserLogin);
}

// Method Description:
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/GlobalAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class TerminalApp::GlobalAppSettings final

GETSET_PROPERTY(bool, SnapToGridOnResize, true);

GETSET_PROPERTY(bool, StartOnUserLogin, false);

private:
GUID _defaultProfile;
winrt::com_ptr<winrt::TerminalApp::implementation::AppKeyBindings> _keybindings;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

// Miscellaneous
"confirmCloseAllTabs": true,
"startOnUserLogin": false,
"theme": "system",
"rowsToScroll": "system",
"snapToGridOnResize": true,
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/lib/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "winrt/Windows.UI.Xaml.Markup.h"
#include "winrt/Windows.UI.Xaml.Documents.h"
#include "winrt/Windows.UI.Xaml.Automation.h"
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.ApplicationModel.DataTransfer.h>

#include <winrt/Microsoft.Toolkit.Win32.UI.XamlHost.h>
Expand Down