Skip to content

Commit 94dab1b

Browse files
feat: add option to choose cursor theme
resolves #5
1 parent 4a1b250 commit 94dab1b

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

CCS.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ Import-LocalizedData @Parameters
2222
#region Preferences
2323
Clear-Host
2424

25+
$Parameters = @{
26+
Message = $Localization.ChooseThemeDialogTitle
27+
Variants = [ordered]@{
28+
'system' = $Localization.System
29+
'dark' = $Localization.Dark
30+
'light' = $Localization.Light
31+
}
32+
Default = 'system'
33+
}
34+
$PrefsManager::CursorTheme = Read-Choice @Parameters
35+
2536
$Parameters = @{
2637
Message = $Localization.TailVersionDialogTitle
2738
Variants = [ordered]@{

Functions.psm1

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ class PathsProvider {
128128
static [hashtable] GetDynamicPaths() {
129129
$useTailVersion = [PrefsManager]::UseTailVersion
130130
$cursorSize = [PrefsManager]::CursorSize
131-
$systemTheme = Get-SystemTheme
131+
$cursorTheme = Get-CursorTheme
132132

133133
return @{
134134
OriginalCursorsFolder = if ($useTailVersion) {
135-
"$([PathsProvider]::OriginalCursorsRootFolder)\$systemTheme\tail"
135+
"$([PathsProvider]::OriginalCursorsRootFolder)\$cursorTheme\tail"
136136
}
137137
else {
138-
"$([PathsProvider]::OriginalCursorsRootFolder)\$systemTheme\default\$cursorSize"
138+
"$([PathsProvider]::OriginalCursorsRootFolder)\$cursorTheme\default\$cursorSize"
139139
}
140140

141141
DiffsFolder = if ($useTailVersion) {
@@ -163,6 +163,7 @@ class PrefsManager {
163163
static [bool] $UseTailVersion = $false
164164
static [string] $CursorSize = 'small'
165165
static [bool] $UseAlternatePrecision = $false
166+
static [string] $CursorTheme = 'system'
166167

167168
static PrefsManager() {
168169
$prefs = [PrefsManager]::Read()
@@ -420,6 +421,20 @@ function Wait-ForRegistryKeyChange {
420421
#endregion System
421422

422423
#region Cursors
424+
function Get-CursorTheme {
425+
[CmdletBinding()]
426+
[OutputType([string])]
427+
param ()
428+
process {
429+
if ([PrefsManager]::CursorTheme -eq 'system') {
430+
Get-SystemTheme
431+
}
432+
else {
433+
[PrefsManager]::CursorTheme
434+
}
435+
}
436+
}
437+
423438
function Copy-Cursors {
424439
[CmdletBinding()]
425440
param ()
@@ -521,13 +536,13 @@ function Edit-Cursors {
521536
$diffsFolder = [PathsProvider]::GetDynamicPaths().DiffsFolder
522537
$cursorsFolder = [PathsProvider]::EditedCursorsFolder
523538

524-
$systemTheme = Get-SystemTheme
539+
$cursorTheme = Get-CursorTheme
525540
$cursorSize = [PrefsManager]::CursorSize
526541
$useTailVersion = [PrefsManager]::UseTailVersion
527542
}
528543
process {
529544
$busyCursor = "$cursorsFolder\busy.ani"
530-
$shouldUseAlternateBusyDiff = (-not($useTailVersion) -and $cursorSize -eq 'big') -and ($systemTheme -eq 'light')
545+
$shouldUseAlternateBusyDiff = (-not($useTailVersion) -and $cursorSize -eq 'big') -and ($cursorTheme -eq 'light')
531546
$busyCursorDiff = if ($shouldUseAlternateBusyDiff) { "$diffsFolder\busy_alt" } else { "$diffsFolder\busy" }
532547

533548
$workingCursor = "$cursorsFolder\working.ani"

Listener.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ $ErrorActionPreference = 'Stop'
77
$root = $PSScriptRoot
88
$functionsModule = "$root\Functions.psm1"
99

10+
Import-Module -Name $functionsModule -Force
11+
Initialize-PathsProvider
12+
$PrefsManager = Initialize-PrefsManager
13+
1014
Remove-Job -Name 'CursorThemeSync' -Force -ErrorAction 'SilentlyContinue'
1115
Remove-Job -Name 'CursorColorSync' -Force -ErrorAction 'SilentlyContinue'
1216
#endregion Preparation
@@ -47,7 +51,9 @@ $cursorThemeSync = {
4751
}
4852
}
4953
}
50-
Start-Job -ScriptBlock $cursorThemeSync -Name 'CursorThemeSync'
54+
if ($PrefsManager::CursorTheme -eq 'system') {
55+
Start-Job -ScriptBlock $cursorThemeSync -Name 'CursorThemeSync'
56+
}
5157
#endregion Theme
5258

5359
#region Accent Color
@@ -87,3 +93,5 @@ $cursorColorSync = {
8793
}
8894
Start-Job -ScriptBlock $cursorColorSync -Name 'CursorColorSync'
8995
#endregion Accent Color
96+
97+
Remove-Module -Name 'Functions'

Resources/Localizations/en-US/Strings.psd1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
ConvertFrom-StringData -StringData @'
22
Yes = Yes
33
No = No
4+
ChooseThemeDialogTitle = Choose cursor theme:
5+
System = System
6+
Dark = Dark
7+
Light = Light
48
ChooseSizeDialogTitle = Choose cursor size:
59
Small = Small
610
Regular = Regular
711
Big = Big
812
TailVersionDialogTitle = Use tail version of cursor?
913
ChoosePrecisionDialogTitle = Use alternate precision cursor?
10-
ListenerDialogTitle = Enable background synchronization for cursor theme and accent color?
14+
ListenerDialogTitle = Enable background synchronization for cursor theme (if the "System" cursor system theme was chosen) and accent color?
1115
ListenerTaskDescription = Runs a script that synchronize cursor with the system theme and accent color in the background
1216
SuccessMessage = Success! Enjoy.
1317
GitHubReminderMessage = Do not forget to star project on GitHub if you liked it: https://github.com/SunsetTechuila/Cursor-Colors-Synchronizer

Resources/Localizations/ru-RU/Strings.psd1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
ConvertFrom-StringData -StringData @'
22
Yes = Да
33
No = Нет
4+
ChooseThemeDialogTitle = Выберите тему курсора:
5+
System = Системная
6+
Dark = Темная
7+
Light = Светлая
48
ChooseSizeDialogTitle = Выберите размер курсора:
59
Small = Маленький
610
Regular = Обычный
711
Big = Большой
812
TailVersionDialogTitle = Использовать версию курсора с хвостом?
913
ChoosePrecisionDialogTitle = Использовать альтернативный курсор для графического выделения?
10-
ListenerDialogTitle = Синхронизировать тему и акцентный цвет курсора в фоновом режиме?
14+
ListenerDialogTitle = Синхронизировать тему (если была выбрана "Системная" тема курсора) и акцентный цвет курсора в фоновом режиме?
1115
ListenerTaskDescription = Запускает скрипт, в фоне синхронизирующий курсор с темой и акцентным цветом Windows
1216
SuccessMessage = Все выполнено без ошибок!
1317
GitHubReminderMessage = Не забудьте оценить проект на GitHub, если он вам понравился: https://github.com/SunsetTechuila/Cursor-Colors-Synchronizer

0 commit comments

Comments
 (0)