-
Notifications
You must be signed in to change notification settings - Fork 0
/
vv.mpv-ipc.ps1
42 lines (33 loc) · 1.25 KB
/
vv.mpv-ipc.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
#Requires -Version 7.2
param (
[string[]] $MpvOptions,
[string] $IPCPipeName = 'ipc_mpv',
[switch] $ShowWindow,
[switch] $Minimized
)
if ($null -eq (Get-Command -Name 'mpv' -ErrorAction Ignore)) {
Write-Host '[mp.ipc] : Error -> Dependency Error: Missing dependency: mpv' -ForegroundColor DarkRed
exit 254
}
$DefinedPipeName = "\\.\pipe\$IPCPipeName"
$SavedCnslwTitle = [Console]::Title
[Console]::Title = "[mp.ipc] mpv IPC server instance (pipe name: ""$IPCPipeName"") is currently running..."
if ($ShowWindow) {
if ($Minimized) {
$MpvStartCmd = "mpv --input-ipc-server=$DefinedPipeName --idle=yes --pause=yes --force-window=yes --window-minimized=yes"
}
else {
$MpvStartCmd = "mpv --input-ipc-server=$DefinedPipeName --idle=yes --pause=yes --force-window=yes"
}
}
else {
$MpvStartCmd = "mpv --input-ipc-server=$DefinedPipeName --idle=yes --pause=yes"
}
if ($MpvOptions) {
$MpvStartCmd = [String]::Concat($MpvStartCmd, ' ', $MpvOptions)
}
[Console]::WriteLine("[mp.ipc] mpv IPC server instance (pipe name: ""$IPCPipeName"") is now starting...")
[Console]::TreatControlCAsInput = $true
Invoke-Expression $MpvStartCmd
[Console]::Title = $SavedCnslwTitle
[Console]::WriteLine("[mp.ipc] mpv IPC server instance (pipe name: ""$IPCPipeName"") just exited...")