Skip to content

Instantly share code, notes, and snippets.

@biutas
Created February 4, 2022 21:24
Show Gist options
  • Save biutas/2a6132170f81319a282c7135abb3dce9 to your computer and use it in GitHub Desktop.
Save biutas/2a6132170f81319a282c7135abb3dce9 to your computer and use it in GitHub Desktop.
Windows Terminal auto dark mode

Auto update terminal scheme based on time

  • Download both PS1 files and place on C:/schedules
  • You can change the scheme on Powershell files!
  • Open Windows Scheduler
  • Import downloaded XML, customize the hour if wanted.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-02-04T18:11:20.5516649</Date>
<Author>biutas</Author>
<URI>\Set Terminal Scheme to Light</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2022-02-04T07:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-3657722525-2464633597-1953754805-1001</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>powershell</Command>
<Arguments>-File C:\schedules\dark-to-light.ps1</Arguments>
</Exec>
</Actions>
</Task>
$from = "One Half Dark"
$to = "One Half Light"
# IF YOU'RE NOT USING PREVIEW VERSION, UPDATE THE PATH BELOW
$settingsPath = $env:LocalAppData + "\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json";
# https://stackoverflow.com/a/30893960
$content = [System.IO.File]::ReadAllText($settingsPath).Replace(
"`"colorScheme`": `"" + $from + "`"",
"`"colorScheme`": `"" + $to + "`"");
[System.IO.File]::WriteAllText($settingsPath, $content);
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-02-04T18:14:24.6569322</Date>
<Author>biutas</Author>
<URI>\Set terminal scheme to dark</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2022-02-04T19:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-3657722525-2464633597-1953754805-1001</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>powershell</Command>
<Arguments>-File C:\schedules\light-to-dark.ps1</Arguments>
</Exec>
</Actions>
</Task>
$from = "One Half Light"
$to = "One Half Dark"
# IF YOU'RE NOT USING PREVIEW VERSION, UPDATE THE PATH BELOW
$settingsPath = $env:LocalAppData + "\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json";
# https://stackoverflow.com/a/30893960
$content = [System.IO.File]::ReadAllText($settingsPath).Replace(
"`"colorScheme`": `"" + $from + "`"",
"`"colorScheme`": `"" + $to + "`"");
[System.IO.File]::WriteAllText($settingsPath, $content);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment