-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpicetifyModule.psm1
More file actions
82 lines (64 loc) · 2.68 KB
/
SpicetifyModule.psm1
File metadata and controls
82 lines (64 loc) · 2.68 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
$script:ModuleRoot = $PSScriptRoot
$script:ModuleInfo = Import-PowerShellDataFile -Path "$($script:ModuleRoot)\SpicetifyModule.psd1"
. "$PSScriptRoot\functions\utils.ps1"
# foreach ($function in (Get-ChildItem "$ModuleRoot\functions" -Filter "*.ps1" -Recurse -ErrorAction Ignore)) {
# . "$function.FullName"
# }
function Get-SpicetifyModuleInfo {
[CmdletBinding()]
param ()
$updateInfo = Get-SpotifyInstalls
$result = New-Object PSObject -Property @{
Version = $script:ModuleInfo.ModuleVersion
SpotifyVersions = ($updateInfo | Select-Object -ExpandProperty Version -Unique | ForEach-Object { $_.ToString() }) -join ', '
SpicetifyPatched = Get-SpicetifyPatchedVersion
}
return $result
}
function Update-Spicetify {
[CmdletBinding()]
param ()
$spotifyVersions = Get-SpotifyInstalls
# if $spotifyVersions is empty, exit
if ($spotifyVersions.Count -eq 0) {
Write-Host "Spotify Not Installed - exiting" -ForegroundColor Red
return
}
# if specetify is not installed, exit
if (-not (Test-Path "$env:USERPROFILE\AppData\Roaming\spicetify")) {
Write-Host "Spicetify Not Installed - exiting" -ForegroundColor Red
return
}
# loop over versions
foreach ($spotifyVersion in $spotifyVersions) {
if ($spotifyVersion.IsStore) {
Write-Host "Spotify Store Version: $($spotifyVersion.Version) - Should not be used" -ForegroundColor Yellow
#remove store version from array if it exists and there are other versions
if ($spotifyVersions.Count -gt 1) {
Write-Host "Removing Store Version as there are other versions available" -ForegroundColor Yellow
$spotifyVersions = $spotifyVersions | Where-Object { $_.IsStore -eq $false }
}
}
}
if ($spotifyVersions.Count -gt 1) {
# output all versions
Write-Host "Multiple Spotify Versions Installed - exiting" -ForegroundColor Red
$spotifyVersions | Format-Table -AutoSize
}
else {
$spotifyVersion = $spotifyVersions[0].Version
$spicetifyPatchedVersion = Get-SpicetifyPatchedVersion
Write-Host "Spotify Version: $spotifyVersion" -ForegroundColor Green
Write-Host "Spicetify Patched Version: $spicetifyPatchedVersion" -ForegroundColor Green
if ($spotifyVersion -ne $spicetifyPatchedVersion) {
Write-Host "Update Required" -ForegroundColor Yellow
# Perform update actions
Stop-Spotify
spicetify backup apply
spicetify update
}
else {
Write-Host "Update Not Required" -ForegroundColor Green
}
}
}