forked from flumiie/spicetify-fluent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
84 lines (72 loc) · 3.08 KB
/
install.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
# Enable TLS 1.2 since it is required for connections to GitHub
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Write-Host "Beginning installation of spicetify-fluent"
Write-Host "https://github.com/williamckha/spicetify-fluent"
# Give time for user to cancel via CTRL+C
Start-Sleep -s 3
$checkSpice = Get-Command spicetify -ErrorAction Silent
if ($null -eq $checkSpice) {
Write-Host -ForegroundColor Red "Spicetify not found. Installing that for you..."
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/khanhas/spicetify-cli/master/install.ps1" | Invoke-Expression
}
# Check if ~\.spicetify-cli\Themes\Fluent directory exists
$spicePath = spicetify -c | Split-Path
$themePath = "$spicePath\Themes\Fluent"
if (-not (Test-Path $themePath)) {
Write-Host "Creating Fluent theme folder..."
New-Item -Path $themePath -ItemType Directory | Out-Null
} else {
# Remove pre-existing files, only keep the newest files
Remove-Item "$themePath\*" -Recurse -Force
}
# Download latest master
$zipUri = "https://github.com/williamckha/spicetify-fluent/archive/refs/heads/master.zip"
$zipSavePath = "$themePath\fluent-master.zip"
Write-Host "Downloading spicetify-fluent latest master..."
Invoke-WebRequest -Uri $zipUri -UseBasicParsing -OutFile $zipSavePath
# Extract theme from .zip file
Write-Host "Extracting..."
Expand-Archive -Path $zipSavePath -DestinationPath $themePath -Force
Get-ChildItem "$themePath\spicetify-fluent-master\*" | ForEach-Object { Move-Item $_ $themePath }
Remove-Item "$themePath\spicetify-fluent-master"
# Delete .zip file
Write-Host "Deleting zip file..."
Remove-Item -Path $zipSavePath
# Change Directory to the Theme Folder
Set-Location $themePath
# Copy the fluent.js to the Extensions folder
Copy-Item fluent.js ..\..\Extensions
Write-Host "+ Installed fluent.js theme"
# Apply the theme with spicetify config calls
spicetify config extensions fluent.js
spicetify config current_theme Fluent
spicetify config color_scheme dark
spicetify config inject_css 1 replace_colors 1 overwrite_assets 1
Write-Host "+ Configured Fluent theme"
# Patch the xpui.js for sidebar fixes
# credit: https://github.com/JulienMaille/dribbblish-dynamic-theme/blob/main/install.ps1
$configFile = Get-Content "$spicePath\config-xpui.ini"
if (-not ($configFile -match "xpui.js_find_8008")) {
$rep = @"
[Patch]
xpui.js_find_8008=,(\w+=)32,
xpui.js_repl_8008=,`${1}58,
"@
# In case missing Patch section
if (-not ($configFile -match "\[Patch\]")) {
$configFile += "`n[Patch]`n"
}
$configFile = $configFile -replace "\[Patch\]",$rep
Set-Content "$spicePath\config-xpui.ini" $configFile
}
Write-Host "+ Patched xpui.js for Sidebar fixes"
# backup apply or just apply where necessary
# credit: https://github.com/JulienMaille/dribbblish-dynamic-theme/blob/main/install.ps1
$backupVer = $configFile -match "^version"
$version = ConvertFrom-StringData $backupVer[0]
if ($version.version.Length -gt 0) {
spicetify apply
} else {
spicetify backup apply
}
Write-Host "+ Applied Theme"