-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathobs-powershell.ps.psm1
52 lines (38 loc) · 1.58 KB
/
obs-powershell.ps.psm1
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
param()
if ((-not (Test-Path '.git')) -or $args -match 'production') {
. $PSScriptRoot/allcommands.ps1
} else {
$CommandsPath = (Join-Path $PSScriptRoot "Commands")
[Include('*-*.ps1')]$CommandsPath
}
$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
Get-OBSEffect | Stop-OBSEffect
if (${obs-powershell}.Beat.Timer) {
${obs-powershell}.Beat.Timer.Stop()
Get-EventSubscriber | Where-Object SourceObject -eq ${obs-powershell}.Beat.Timer | Unregister-Event
}
Disconnect-OBS
}
$myModule = $MyInvocation.MyCommand.ScriptBlock.Module
$NewDriveSplat = @{PSProvider='FileSystem';ErrorAction='Ignore';Scope='Global'}
New-PSDrive -Name $myModule.Name -Root $PSScriptRoot -Description "$MyModule" @NewDriveSplat
if ($home) {
New-PSDrive -Name "my-$($MyModule.Name)" -Root (Join-Path $home ".$($myModule.Name)") -Description "My $MyModule" @NewDriveSplat
}
#region obs-powershell startup
foreach ($noun in 'Streaming','Recording') {
foreach ($verb in 'Start', 'Stop') {
Set-Alias "$verb-$noun" "$verb-OBS$($noun -replace 'ing')"
}
}
Connect-OBS
$script:OBS = ${script:OBS-PowerShell} = $MyInvocation.MyCommand.ScriptBlock.Module
$script:OBS | Import-OBSEffect
$script:OBS.pstypenames.insert(0,'obs.powershell')
$ModuleProfilePath = $Profile | Split-Path | Join-Path -ChildPath "$($script:OBS.Name).profile.ps1"
$script:variablesToExport = @('obs','obs-powershell')
if (Test-Path $ModuleProfilePath) {
. $ModuleProfilePath
}
#endregion obs-powershell startup
Export-ModuleMember -Function * -Variable $script:variablesToExport -Alias *