-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
88 lines (74 loc) · 3.81 KB
/
Copy pathinstall.ps1
File metadata and controls
88 lines (74 loc) · 3.81 KB
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
# random-library Spicetify installer
# One-liner: iwr -useb "https://raw.githubusercontent.com/daviidpaark/random-library/main/install.ps1" | iex
$repoBaseUrl = "https://raw.githubusercontent.com/daviidpaark/random-library/main"
$appsToInstall = @("random-library")
$appsToClean = @("random-albums")
$appFiles = @{
"random-library" = @("index.js", "manifest.json")
}
$ErrorActionPreference = "Stop"
# ── 1. Verify spicetify is installed ────────────────────────────────────────
if (-not (Get-Command spicetify -ErrorAction SilentlyContinue)) {
Write-Error "spicetify not found in PATH. Install it from https://spicetify.app first."
exit 1
}
$spiceConfigPath = & spicetify -c 2>$null
if ($spiceConfigPath -and (Test-Path $spiceConfigPath)) {
$spicePath = Split-Path $spiceConfigPath -Parent
$configFile = $spiceConfigPath
} else {
$spicePath = "$env:APPDATA\spicetify"
$configFile = "$spicePath\config-xpui.ini"
}
if (-not (Test-Path $configFile)) {
Write-Error "config-xpui.ini not found at $configFile. Run 'spicetify backup' first."
exit 1
}
# ── 2. Clean old apps if present ─────────────────────────────────────────────
foreach ($oldApp in $appsToClean) {
$oldDest = Join-Path $spicePath "CustomApps\$oldApp"
if (Test-Path $oldDest) {
Remove-Item $oldDest -Recurse -Force
Write-Host "Removed legacy $oldApp folder" -ForegroundColor DarkGray
}
}
# ── 3. Copy/download custom app files ───────────────────────────────────────
foreach ($app in $appsToInstall) {
$dest = Join-Path $spicePath "CustomApps\$app"
$localSrc = if ($PSScriptRoot) { Join-Path $PSScriptRoot $app } else { $null }
Write-Host "Installing $app..." -ForegroundColor Cyan
if (Test-Path $dest) { Remove-Item $dest -Recurse -Force }
New-Item -ItemType Directory -Path $dest -Force | Out-Null
if ($localSrc -and (Test-Path $localSrc)) {
Copy-Item "$localSrc\*" $dest -Recurse
Write-Host " Copied to $dest" -ForegroundColor Green
} else {
foreach ($file in $appFiles[$app]) {
$url = "$repoBaseUrl/$app/$file"
Write-Host " Downloading $file..." -ForegroundColor DarkCyan
Invoke-WebRequest -Uri $url -OutFile (Join-Path $dest $file) -UseBasicParsing
}
Write-Host " Downloaded to $dest" -ForegroundColor Green
}
}
# ── 4. Register apps in config-xpui.ini ─────────────────────────────────────
$config = Get-Content $configFile -Raw
if ($config -match "(?m)^(custom_apps\s*=\s*)(.*)$") {
$key = $Matches[1]
$values = $Matches[2] -split "\|" | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" -and $appsToClean -notcontains $_ }
foreach ($app in $appsToInstall) {
if ($values -notcontains $app) {
$values += $app
Write-Host "Registered '$app' in config-xpui.ini" -ForegroundColor Green
} else {
Write-Host "'$app' already registered in config-xpui.ini" -ForegroundColor Yellow
}
}
$newLine = "$key$($values -join '|')"
$config = $config -replace "(?m)^custom_apps\s*=.*$", $newLine
Set-Content $configFile $config -NoNewline
}
# ── 5. Apply ─────────────────────────────────────────────────────────────────
Write-Host "`nApplying spicetify..." -ForegroundColor Cyan
spicetify apply
Write-Host "`nDone! Restart Spotify if it's already open." -ForegroundColor Green