2424
2525. PARAMETER InstallShaders
2626 If specified, downloads and installs shaders via tools/install/download_shaders.ps1.
27+
28+ . PARAMETER Full
29+ If specified, performs a full installation: MPV, Plugins, Shaders, and Registration.
2730#>
2831[CmdletBinding (SupportsShouldProcess = $true )]
2932param (
3033 [switch ]$Check ,
3134 [switch ]$InstallPlugins ,
32- [switch ]$InstallShaders
35+ [switch ]$InstallShaders ,
36+ [switch ]$Full
3337)
3438
3539Set-StrictMode - Version Latest
@@ -44,6 +48,172 @@ if (-not $sourcePath) {
4448$sourcePath = (Resolve-Path $sourcePath ).Path
4549$toolsDir = Join-Path $sourcePath " tools/install"
4650
51+ # -----------------------------------------------------------------------------
52+ # Configuration Initialization
53+ # -----------------------------------------------------------------------------
54+ # Ensure mpv_local.conf exists
55+ $localConfPath = Join-Path $sourcePath " mpv_local.conf"
56+ if (-not (Test-Path $localConfPath )) {
57+ Write-Host " Creating empty mpv_local.conf..."
58+ New-Item - Path $localConfPath - ItemType File - Force | Out-Null
59+ }
60+
61+ if ($Full ) {
62+ Write-Host " Full installation mode selected." - ForegroundColor Cyan
63+ $InstallPlugins = $true
64+ $InstallShaders = $true
65+ }
66+
67+ $doExtras = $InstallPlugins -or $InstallShaders
68+ $doCore = (-not $doExtras ) -or $Full
69+ $doRegister = $IsWindows -and $doCore
70+
71+ if (-not $Check ) {
72+ Write-Host " Source Config Path: $sourcePath "
73+ }
74+
75+ # -----------------------------------------------------------------------------
76+ # Core Installation (mpv + link)
77+ # -----------------------------------------------------------------------------
78+ if ($doCore -and -not $Check ) {
79+ if ($IsWindows ) {
80+ Write-Host " Detected OS: Windows"
81+
82+ # Check if scoop is installed
83+ if (! (Get-Command scoop - ErrorAction SilentlyContinue)) {
84+ Write-Error " Scoop is not installed. Please install Scoop first (https://scoop.sh)."
85+ exit 1
86+ }
87+
88+ Write-Host " Checking if mpv is already installed..."
89+ $mpvPrefix = scoop prefix mpv 2> $null
90+ if ($null -eq $mpvPrefix -or ! (Test-Path $mpvPrefix )) {
91+ Write-Host " mpv not found. Installing via scoop..."
92+ scoop install mpv
93+ }
94+ else {
95+ Write-Host " mpv is already installed at: $mpvPrefix "
96+ }
97+
98+ # Locate mpv installation again to be sure (or use the one we found)
99+ try {
100+ $mpvPath = scoop prefix mpv
101+ }
102+ catch {
103+ Write-Error " Failed to determine mpv path using 'scoop prefix mpv'."
104+ exit 1
105+ }
106+
107+ if (! (Test-Path $mpvPath )) {
108+ Write-Error " Could not find mpv installation at $mpvPath "
109+ exit 1
110+ }
111+
112+ # Define target path for portable_config
113+ $targetPath = Join-Path $mpvPath " portable_config"
114+ Write-Host " Target Path: $targetPath "
115+
116+ # Handle existing target
117+ if (Test-Path $targetPath ) {
118+ $item = Get-Item $targetPath
119+ # Check if it is a reparse point (symlink/junction)
120+ if ($item.Attributes.HasFlag ([System.IO.FileAttributes ]::ReparsePoint)) {
121+ Write-Host " Removing existing link..."
122+
123+ # Ensure mpv is not running
124+ Get-Process mpv - ErrorAction SilentlyContinue | Stop-Process - Force
125+
126+ # Remove ReadOnly attribute if present
127+ if ($item.Attributes.HasFlag ([System.IO.FileAttributes ]::ReadOnly)) {
128+ $item.Attributes = $item.Attributes -band -not [System.IO.FileAttributes ]::ReadOnly
129+ }
130+
131+ # Use cmd /c rmdir which is more reliable for removing junctions than Remove-Item
132+ cmd / c " rmdir `" $targetPath `" "
133+
134+ if (Test-Path $targetPath ) {
135+ # Fallback to .NET method
136+ try { [System.IO.Directory ]::Delete($targetPath ) } catch {}
137+ }
138+
139+ if (Test-Path $targetPath ) {
140+ Remove-Item $targetPath - Force
141+ }
142+ }
143+ else {
144+ Write-Warning " Directory '$targetPath ' already exists and is not a link."
145+ $confirm = Read-Host " Do you want to delete it and replace with symlink? (y/n)"
146+ if ($confirm -eq ' y' ) {
147+ Remove-Item $targetPath - Recurse - Force
148+ }
149+ else {
150+ Write-Error " Aborted."
151+ exit 1
152+ }
153+ }
154+ }
155+
156+ # Create Junction
157+ Write-Host " Creating Junction..."
158+ New-Item - ItemType Junction - Path $targetPath - Target $sourcePath | Out-Null
159+ Write-Host " Success! mpv is now using this portable_config."
160+ }
161+ elseif ($IsMacOS -or $IsLinux ) {
162+ if ($IsMacOS ) { Write-Host " Detected OS: macOS" }
163+ else { Write-Host " Detected OS: Linux" }
164+
165+ # Check for Homebrew
166+ if (! (Get-Command brew - ErrorAction SilentlyContinue)) {
167+ Write-Error " Homebrew is not installed. Please install Homebrew first."
168+ exit 1
169+ }
170+
171+ Write-Host " Installing/Updating mpv via Homebrew..."
172+ brew install mpv
173+
174+ # Define target path (~/.config/mpv)
175+ $configDir = Join-Path $HOME " .config"
176+ $targetPath = Join-Path $configDir " mpv"
177+ Write-Host " Target Path: $targetPath "
178+
179+ # Handle existing target
180+ if (Test-Path $targetPath ) {
181+ # Check if it's a symlink
182+ $isSymlink = (Get-Item $targetPath ).LinkType -ne $null
183+
184+ if ($isSymlink ) {
185+ Write-Host " Removing existing symlink..."
186+ Remove-Item $targetPath - Force
187+ }
188+ else {
189+ Write-Warning " Directory '$targetPath ' already exists and is not a symlink."
190+ $confirm = Read-Host " Do you want to overwrite it with a symlink to this repo? (y/n)"
191+ if ($confirm -eq ' y' ) {
192+ Remove-Item $targetPath - Recurse - Force
193+ }
194+ else {
195+ Write-Error " Aborted."
196+ exit 1
197+ }
198+ }
199+ }
200+
201+ # Ensure parent directory exists
202+ if (! (Test-Path $configDir )) {
203+ New-Item - ItemType Directory - Path $configDir | Out-Null
204+ }
205+
206+ # Create Symlink
207+ Write-Host " Creating Symlink..."
208+ New-Item - ItemType SymbolicLink - Path $targetPath - Target $sourcePath | Out-Null
209+ Write-Host " Success! Linked $sourcePath to $targetPath "
210+ }
211+ else {
212+ Write-Error " Unsupported Operating System."
213+ exit 1
214+ }
215+ }
216+
47217# -----------------------------------------------------------------------------
48218# Plugin Installation (uosc, thumbfast)
49219# -----------------------------------------------------------------------------
@@ -70,12 +240,18 @@ if ($InstallShaders) {
70240 }
71241}
72242
73- if ($InstallPlugins -or $InstallShaders ) {
74- if (-not $Check ) { exit 0 }
75- }
76-
77- if (-not $Check ) {
78- Write-Host " Source Config Path: $sourcePath "
243+ # -----------------------------------------------------------------------------
244+ # Register mpv as a system-wide handler (Windows only)
245+ # -----------------------------------------------------------------------------
246+ if ($doRegister -and -not $Check ) {
247+ $registerScript = Join-Path $toolsDir " registerMpv.ps1"
248+ if (Test-Path $registerScript ) {
249+ Write-Host " Registering mpv as system-wide handler..."
250+ & $registerScript
251+ }
252+ else {
253+ Write-Warning " Registration script not found at $registerScript "
254+ }
79255}
80256
81257# -----------------------------------------------------------------------------
@@ -153,164 +329,9 @@ if ($Check) {
153329 if ($isInstalled ) { exit 0 } else { exit 1 }
154330}
155331
156- # -----------------------------------------------------------------------------
157- # Windows Implementation (Scoop)
158- # -----------------------------------------------------------------------------
159- if ($IsWindows ) {
160- Write-Host " Detected OS: Windows"
161-
162- # Check if scoop is installed
163- if (! (Get-Command scoop - ErrorAction SilentlyContinue)) {
164- Write-Error " Scoop is not installed. Please install Scoop first (https://scoop.sh)."
165- exit 1
166- }
167-
168- Write-Host " Checking if mpv is already installed..."
169- $mpvPrefix = scoop prefix mpv 2> $null
170- if ($null -eq $mpvPrefix -or ! (Test-Path $mpvPrefix )) {
171- Write-Host " mpv not found. Installing via scoop..."
172- scoop install mpv
173- }
174- else {
175- Write-Host " mpv is already installed at: $mpvPrefix "
176- }
177-
178- # Locate mpv installation again to be sure (or use the one we found)
179- try {
180- $mpvPath = scoop prefix mpv
181- }
182- catch {
183- Write-Error " Failed to determine mpv path using 'scoop prefix mpv'."
184- exit 1
185- }
186-
187- if (! (Test-Path $mpvPath )) {
188- Write-Error " Could not find mpv installation at $mpvPath "
189- exit 1
190- }
191-
192- # Define target path for portable_config
193- $targetPath = Join-Path $mpvPath " portable_config"
194- Write-Host " Target Path: $targetPath "
195-
196- # Handle existing target
197- if (Test-Path $targetPath ) {
198- $item = Get-Item $targetPath
199- # Check if it is a reparse point (symlink/junction)
200- if ($item.Attributes.HasFlag ([System.IO.FileAttributes ]::ReparsePoint)) {
201- Write-Host " Removing existing link..."
202-
203- # Ensure mpv is not running
204- Get-Process mpv - ErrorAction SilentlyContinue | Stop-Process - Force
205-
206- # Remove ReadOnly attribute if present
207- if ($item.Attributes.HasFlag ([System.IO.FileAttributes ]::ReadOnly)) {
208- $item.Attributes = $item.Attributes -band -not [System.IO.FileAttributes ]::ReadOnly
209- }
210-
211- # Use cmd /c rmdir which is more reliable for removing junctions than Remove-Item
212- cmd / c " rmdir `" $targetPath `" "
213-
214- if (Test-Path $targetPath ) {
215- # Fallback to .NET method
216- try { [System.IO.Directory ]::Delete($targetPath ) } catch {}
217- }
218-
219- if (Test-Path $targetPath ) {
220- Remove-Item $targetPath - Force
221- }
222- }
223- else {
224- Write-Warning " Directory '$targetPath ' already exists and is not a link."
225- $confirm = Read-Host " Do you want to delete it and replace with symlink? (y/n)"
226- if ($confirm -eq ' y' ) {
227- Remove-Item $targetPath - Recurse - Force
228- }
229- else {
230- Write-Error " Aborted."
231- exit 1
232- }
233- }
234- }
235-
236- # Create Junction
237- Write-Host " Creating Junction..."
238- New-Item - ItemType Junction - Path $targetPath - Target $sourcePath | Out-Null
239- Write-Host " Success! mpv is now using this portable_config."
240-
241- # -----------------------------------------------------------------------------
242- # Register mpv as a system-wide handler (Windows only)
243- # -----------------------------------------------------------------------------
244- $registerScript = Join-Path $toolsDir " registerMpv.ps1"
245- if (Test-Path $registerScript ) {
246- Write-Host " Registering mpv as system-wide handler..."
247- & $registerScript
248- }
249- else {
250- Write-Warning " Registration script not found at $registerScript "
251- }
252- }
253-
254- # -----------------------------------------------------------------------------
255- # macOS / Linux Implementation (Homebrew)
256- # -----------------------------------------------------------------------------
257- elseif ($IsMacOS -or $IsLinux ) {
258- if ($IsMacOS ) { Write-Host " Detected OS: macOS" }
259- else { Write-Host " Detected OS: Linux" }
260-
261- # Check for Homebrew
262- if (! (Get-Command brew - ErrorAction SilentlyContinue)) {
263- Write-Error " Homebrew is not installed. Please install Homebrew first."
264- exit 1
265- }
266-
267- Write-Host " Installing/Updating mpv via Homebrew..."
268- brew install mpv
269-
270- # Define target path (~/.config/mpv)
271- $configDir = Join-Path $HOME " .config"
272- $targetPath = Join-Path $configDir " mpv"
273- Write-Host " Target Path: $targetPath "
274-
275- # Handle existing target
276- if (Test-Path $targetPath ) {
277- # Check if it's a symlink
278- $isSymlink = (Get-Item $targetPath ).LinkType -ne $null
279-
280- if ($isSymlink ) {
281- Write-Host " Removing existing symlink..."
282- Remove-Item $targetPath - Force
283- }
284- else {
285- Write-Warning " Directory '$targetPath ' already exists and is not a symlink."
286- $confirm = Read-Host " Do you want to overwrite it with a symlink to this repo? (y/n)"
287- if ($confirm -eq ' y' ) {
288- Remove-Item $targetPath - Recurse - Force
289- }
290- else {
291- Write-Error " Aborted."
292- exit 1
293- }
294- }
295- }
296-
297- # Ensure parent directory exists
298- if (! (Test-Path $configDir )) {
299- New-Item - ItemType Directory - Path $configDir | Out-Null
300- }
301-
302- # Create Symlink
303- Write-Host " Creating Symlink..."
304- New-Item - ItemType SymbolicLink - Path $targetPath - Target $sourcePath | Out-Null
305- Write-Host " Success! Linked $sourcePath to $targetPath "
306- }
307- else {
308- Write-Error " Unsupported Operating System."
309- exit 1
310- }
311-
312- if (-not $Check ) {
332+ if (-not $Check -and -not $Full ) {
313333 Write-Host " `n [Tip] You can install extras by running:" - ForegroundColor Yellow
314334 Write-Host " .\install.ps1 -InstallPlugins" - ForegroundColor Yellow
315335 Write-Host " .\install.ps1 -InstallShaders" - ForegroundColor Yellow
336+ Write-Host " .\install.ps1 -Full" - ForegroundColor Yellow
316337}
0 commit comments