Skip to content

Commit 7427b84

Browse files
Release
0 parents  commit 7427b84

File tree

137 files changed

+582
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+582
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
Resources/Preferences
3+
Resources/Custom Cursor/*

CCS.ps1

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#Requires -RunAsAdministrator
2+
#Requires -Version 5.1
3+
4+
#region Preparation
5+
$ErrorActionPreference = 'Stop'
6+
[Console]::Title = 'Cursor Colors Synchronizer'
7+
Remove-Module -Name Functions -ErrorAction SilentlyContinue
8+
Clear-Variable -Name Localization, windowsTheme, cursorSize, useClassicWheel, useAlternatePrecision, originalCursorFolder, customCursorFolder, byteDiffFolder, useListener, input -ErrorAction SilentlyContinue
9+
Import-LocalizedData -BindingVariable Localization -BaseDirectory $PSScriptRoot\Localizations -FileName Strings
10+
Import-Module -Name $PSScriptRoot\Functions.ps1
11+
#endregion
12+
13+
#region Dialogs
14+
do {
15+
Clear-Host
16+
Write-Host
17+
Write-Host -Object $Localization.ChooseSizeDialogTitle
18+
Write-Host
19+
Write-Host -Object ('1) ' + $Localization.Small)
20+
Write-Host -Object ('2) ' + $Localization.Regular)
21+
Write-Host -Object ('3) ' + $Localization.Big)
22+
Write-Host
23+
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
24+
} until ( Validate-Input -Object $input -Values (1..3) )
25+
switch ($input) {
26+
1 {$cursorSize = 'small'}
27+
2 {$cursorSize = 'regular'}
28+
3 {$cursorSize = 'big'}
29+
}
30+
31+
do {
32+
Clear-Host
33+
Write-Host
34+
Write-Host -Object $Localization.ChooseWheelDialogTitle
35+
Write-Host
36+
Write-Host -Object ('1) ' + $Localization.No)
37+
Write-Host -Object ('2) ' + $Localization.Yes)
38+
Write-Host
39+
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
40+
} until ( Validate-Input -Object $input -Values (1..2) )
41+
switch ($input) {
42+
1 {$useClassicWheel = $false}
43+
2 {$useClassicWheel = $true}
44+
}
45+
46+
do {
47+
Clear-Host
48+
Write-Host
49+
Write-Host -Object $Localization.ChoosePrecisionDialogTitle
50+
Write-Host
51+
Write-Host -Object ('1) ' + $Localization.Yes)
52+
Write-Host -Object ('2) ' + $Localization.No)
53+
Write-Host
54+
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
55+
} until ( Validate-Input -Object $input -Values (1..2) )
56+
switch ($input) {
57+
1 {$useAlternatePrecision = $true}
58+
2 {$useAlternatePrecision = $false}
59+
}
60+
61+
do {
62+
Clear-Host
63+
Write-Host
64+
Write-Host -Object $Localization.ListenerDialogTitle
65+
Write-Host
66+
Write-Host -Object ('1) ' + $Localization.Yes)
67+
Write-Host -Object ('2) ' + $Localization.No)
68+
Write-Host
69+
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
70+
} until ( Validate-Input -Object $input -Values (1..2) )
71+
switch ($input) {
72+
1 {$useListener = $true}
73+
2 {$useListener = $false}
74+
}
75+
#endregion
76+
77+
78+
#region Variables
79+
$windowsTheme = Get-WindowsTheme
80+
$originalCursorFolder = "$PSScriptRoot\Resources\Original Cursors\$windowsTheme\$cursorSize"
81+
$byteDiffFolder = "$PSScriptRoot\Resources\Byte Diff\$cursorSize"
82+
$customCursorFolder = "$PSScriptRoot\Resources\Custom Cursor"
83+
#endregion
84+
85+
#region Cursor
86+
Copy-Item -Path $originalCursorFolder\default\* -Destination $customCursorFolder -Recurse -Force
87+
if ($useClassicWheel -eq $false) {
88+
if ( ($windowsTheme -eq 'light') -and ($cursorSize -eq 'big') ) {
89+
Create-PatchedCursorFiles -CursorPath $originalCursorFolder\default -DiffPath $byteDiffFolder -UseAlternateDiff $true
90+
}
91+
else {
92+
Create-PatchedCursorFiles -CursorPath $originalCursorFolder\default -DiffPath $byteDiffFolder
93+
}
94+
}
95+
else {
96+
Copy-Item -Path $originalCursorFolder\alternatives\busy.ani -Destination $customCursorFolder -Force
97+
Copy-Item -Path $originalCursorFolder\alternatives\working.ani -Destination $customCursorFolder -Force
98+
}
99+
if ($useAlternatePrecision) {
100+
Copy-Item -Path $originalCursorFolder\alternatives\precision.cur -Destination $customCursorFolder -Force
101+
}
102+
Install-CursorFromFolder -Path $customCursorFolder
103+
Apply-Changes
104+
#endregion
105+
106+
#region Parameters
107+
Set-Content -Path $PSScriptRoot\Resources\Preferences -Value $cursorSize
108+
Add-Content -Path $PSScriptRoot\Resources\Preferences -Value $useClassicWheel
109+
Add-Content -Path $PSScriptRoot\Resources\Preferences -Value $useAlternatePrecision
110+
#endregion
111+
112+
#region Listener
113+
if ($useListener) {
114+
$name = 'CCS Listener'
115+
$action = New-ScheduledTaskAction -Execute powershell.exe -Argument ("-ExecutionPolicy Bypass -WindowStyle Hidden -File $PSScriptRoot\Listener.ps1")
116+
$user = whoami
117+
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $user
118+
$description = $Localization.ListenerTaskDescription
119+
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable -DontStopIfGoingOnBatteries -ExecutionTimeLimit '00:00:00'
120+
Stop-ScheduledTask -TaskName $name -ErrorAction SilentlyContinue
121+
Register-ScheduledTask -TaskName $name -Description $description -Action $action -Trigger $trigger -Settings $settings -RunLevel Highest -Force | Out-Null
122+
Start-Sleep 1
123+
Start-ScheduledTask -TaskName $name
124+
}
125+
#endregion
126+
127+
#region Final Messages
128+
Clear-Host
129+
Write-Host
130+
Write-Host -Object $Localization.SuccessMessage -ForegroundColor Green
131+
Write-Host
132+
Write-Host -Object $Localization.GitHubReminderMessage
133+
Write-Host
134+
Pause
135+
exit
136+
#endregion

0 commit comments

Comments
 (0)