-
Notifications
You must be signed in to change notification settings - Fork 2
/
CCS.ps1
103 lines (90 loc) · 2.82 KB
/
CCS.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#Requires -RunAsAdministrator
#Requires -Version 5.1
#region Preparation
$ErrorActionPreference = 'Stop'
$previousWindowTitle = $Host.UI.RawUI.WindowTitle
$Host.UI.RawUI.WindowTitle = 'Cursor Colors Synchronizer'
Import-Module -Name "$PSScriptRoot\Functions.psm1" -Force
$PathsProvider = Initialize-PathsProvider
$PrefsManager = Initialize-PrefsManager
$Parameters = @{
BindingVariable = 'Localization'
BaseDirectory = $PathsProvider::LocalizationsFolder
FileName = 'Strings'
}
Import-LocalizedData @Parameters
#endregion Preparation
#region Preferences
Clear-Host
$Parameters = @{
Message = $Localization.TailVersionDialogTitle
Variants = [ordered]@{
$true = $Localization.Yes
$false = $Localization.No
}
Default = $false
}
$PrefsManager::UseTailVersion = Read-Choice @Parameters
if (-not ($PrefsManager::UseTailVersion)) {
$Parameters = @{
Message = $Localization.ChooseSizeDialogTitle
Variants = [ordered]@{
small = $Localization.Small
regular = $Localization.Regular
big = $Localization.Big
}
}
$PrefsManager::CursorSize = Read-Choice @Parameters
$Parameters = @{
Message = $Localization.ChoosePrecisionDialogTitle
Variants = [ordered]@{
$true = $Localization.Yes
$false = $Localization.No
}
Default = $false
}
$PrefsManager::UseAlternatePrecision = Read-Choice @Parameters
}
$Parameters = @{
Message = $Localization.ListenerDialogTitle
Variants = [ordered]@{
$true = $Localization.Yes
$false = $Localization.No
}
}
$installListener = Read-Choice @Parameters
$PrefsManager::Save()
#endregion Preferences
#region Cursor
Copy-Cursors
Edit-Cursors
Install-Cursors
#endregion Cursor
#region Listener
if ($installListener) {
$Parameters = @{
TaskName = 'CCS Listener'
Description = $Localization.ListenerTaskDescription
Action = New-ScheduledTaskAction -Execute $PathsProvider::RunHidden -Argument "powershell -ExecutionPolicy Bypass -NoExit -File `"$($PathsProvider::Listener)`""
Trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME
Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable -DontStopIfGoingOnBatteries -ExecutionTimeLimit '00:00:00'
RunLevel = 'Highest'
Force = $true
}
Stop-ScheduledTask -TaskName $Parameters.TaskName -ErrorAction 'SilentlyContinue'
Register-ScheduledTask @Parameters | Out-Null
Start-Sleep -Seconds 1
Start-ScheduledTask -TaskName $Parameters.TaskName
}
#endregion Listener
#region Final Messages
Write-Host
Write-Host -Object $Localization.SuccessMessage -ForegroundColor 'Green'
Write-Host
Write-Host -Object $Localization.GitHubReminderMessage
Write-Host
Remove-Module -Name 'Functions'
$Host.UI.RawUI.WindowTitle = $previousWindowTitle
Pause
exit
#endregion Final Messages