Skip to content

Commit

Permalink
Release
Browse files Browse the repository at this point in the history
  • Loading branch information
SunsetTechuila committed Feb 14, 2023
0 parents commit 7427b84
Show file tree
Hide file tree
Showing 137 changed files with 582 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

Resources/Preferences
Resources/Custom Cursor/*
136 changes: 136 additions & 0 deletions CCS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#Requires -RunAsAdministrator
#Requires -Version 5.1

#region Preparation
$ErrorActionPreference = 'Stop'
[Console]::Title = 'Cursor Colors Synchronizer'
Remove-Module -Name Functions -ErrorAction SilentlyContinue
Clear-Variable -Name Localization, windowsTheme, cursorSize, useClassicWheel, useAlternatePrecision, originalCursorFolder, customCursorFolder, byteDiffFolder, useListener, input -ErrorAction SilentlyContinue
Import-LocalizedData -BindingVariable Localization -BaseDirectory $PSScriptRoot\Localizations -FileName Strings
Import-Module -Name $PSScriptRoot\Functions.ps1
#endregion

#region Dialogs
do {
Clear-Host
Write-Host
Write-Host -Object $Localization.ChooseSizeDialogTitle
Write-Host
Write-Host -Object ('1) ' + $Localization.Small)
Write-Host -Object ('2) ' + $Localization.Regular)
Write-Host -Object ('3) ' + $Localization.Big)
Write-Host
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
} until ( Validate-Input -Object $input -Values (1..3) )
switch ($input) {
1 {$cursorSize = 'small'}
2 {$cursorSize = 'regular'}
3 {$cursorSize = 'big'}
}

do {
Clear-Host
Write-Host
Write-Host -Object $Localization.ChooseWheelDialogTitle
Write-Host
Write-Host -Object ('1) ' + $Localization.No)
Write-Host -Object ('2) ' + $Localization.Yes)
Write-Host
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
} until ( Validate-Input -Object $input -Values (1..2) )
switch ($input) {
1 {$useClassicWheel = $false}
2 {$useClassicWheel = $true}
}

do {
Clear-Host
Write-Host
Write-Host -Object $Localization.ChoosePrecisionDialogTitle
Write-Host
Write-Host -Object ('1) ' + $Localization.Yes)
Write-Host -Object ('2) ' + $Localization.No)
Write-Host
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
} until ( Validate-Input -Object $input -Values (1..2) )
switch ($input) {
1 {$useAlternatePrecision = $true}
2 {$useAlternatePrecision = $false}
}

do {
Clear-Host
Write-Host
Write-Host -Object $Localization.ListenerDialogTitle
Write-Host
Write-Host -Object ('1) ' + $Localization.Yes)
Write-Host -Object ('2) ' + $Localization.No)
Write-Host
$input = Read-Host -Prompt $Localization.ChooseDialogPromt
} until ( Validate-Input -Object $input -Values (1..2) )
switch ($input) {
1 {$useListener = $true}
2 {$useListener = $false}
}
#endregion


#region Variables
$windowsTheme = Get-WindowsTheme
$originalCursorFolder = "$PSScriptRoot\Resources\Original Cursors\$windowsTheme\$cursorSize"
$byteDiffFolder = "$PSScriptRoot\Resources\Byte Diff\$cursorSize"
$customCursorFolder = "$PSScriptRoot\Resources\Custom Cursor"
#endregion

#region Cursor
Copy-Item -Path $originalCursorFolder\default\* -Destination $customCursorFolder -Recurse -Force
if ($useClassicWheel -eq $false) {
if ( ($windowsTheme -eq 'light') -and ($cursorSize -eq 'big') ) {
Create-PatchedCursorFiles -CursorPath $originalCursorFolder\default -DiffPath $byteDiffFolder -UseAlternateDiff $true
}
else {
Create-PatchedCursorFiles -CursorPath $originalCursorFolder\default -DiffPath $byteDiffFolder
}
}
else {
Copy-Item -Path $originalCursorFolder\alternatives\busy.ani -Destination $customCursorFolder -Force
Copy-Item -Path $originalCursorFolder\alternatives\working.ani -Destination $customCursorFolder -Force
}
if ($useAlternatePrecision) {
Copy-Item -Path $originalCursorFolder\alternatives\precision.cur -Destination $customCursorFolder -Force
}
Install-CursorFromFolder -Path $customCursorFolder
Apply-Changes
#endregion

#region Parameters
Set-Content -Path $PSScriptRoot\Resources\Preferences -Value $cursorSize
Add-Content -Path $PSScriptRoot\Resources\Preferences -Value $useClassicWheel
Add-Content -Path $PSScriptRoot\Resources\Preferences -Value $useAlternatePrecision
#endregion

#region Listener
if ($useListener) {
$name = 'CCS Listener'
$action = New-ScheduledTaskAction -Execute powershell.exe -Argument ("-ExecutionPolicy Bypass -WindowStyle Hidden -File $PSScriptRoot\Listener.ps1")
$user = whoami
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $user
$description = $Localization.ListenerTaskDescription
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable -DontStopIfGoingOnBatteries -ExecutionTimeLimit '00:00:00'
Stop-ScheduledTask -TaskName $name -ErrorAction SilentlyContinue
Register-ScheduledTask -TaskName $name -Description $description -Action $action -Trigger $trigger -Settings $settings -RunLevel Highest -Force | Out-Null
Start-Sleep 1
Start-ScheduledTask -TaskName $name
}
#endregion

#region Final Messages
Clear-Host
Write-Host
Write-Host -Object $Localization.SuccessMessage -ForegroundColor Green
Write-Host
Write-Host -Object $Localization.GitHubReminderMessage
Write-Host
Pause
exit
#endregion
Loading

0 comments on commit 7427b84

Please sign in to comment.