-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTVMode.ps1
56 lines (44 loc) · 2.78 KB
/
TVMode.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# requires https://github.com/frgnca/AudioDeviceCmdlets
# requires http://www.nirsoft.net/utils/multi_monitor_tool.html
Add-Type -AssemblyName PresentationCore,PresentationFramework
$allAudio = Get-AudioDevice -List
# foreach ($audioDevice in $allAudio){
# Write-Host $audioDevice.name
# if ($audioDevice.name -eq "Realtek HD Audio 2nd output (Realtek(R) Audio)") {
# Write-Host "ladies and gentlemen, we got 'em"
# }
# }
$headphoneName = "Realtek HD Audio 2nd output (Realtek(R) Audio)"
$speakerName = "Realtek Digital Output (Realtek(R) Audio)"
$headphonesExist = ($allAudio.name -contains $headphoneName)
$speakersExist = ($allAudio.name -contains $speakerName)
if (-Not $headphonesExist -Or -Not $speakersExist) {
$errorText = "Something went wrong!"
if (-Not $headphonesExist) {
$errorText = "$errorText `nHeadphone device is missing!`nIt should be called $headphoneName"
}
if (-Not $speakersExist) {
$errorText = "$errorText `nSpeaker device is missing!`nIt should be called $speakerName"
}
$errorText =
[System.Windows.MessageBox]::Show($errorText)
}
$headphoneDevice = ($allAudio | Where-Object {$_.name -eq $headphoneName})
$speakerDevice = ($allAudio | Where-Object {$_.name -eq $speakerName})
$currentDefaultAudioDevice = Get-AudioDevice -Playback
if ($currentDefaultAudioDevice.name -eq $headphoneDevice.name) {
Write-Host "switching to speaker mode"
Set-AudioDevice -ID $speakerDevice.ID
# Small off, LG off, TV on
# MultiMonitorTool.exe /SetMonitors "Name=MONITOR\SAM0D3B\{4d36e96e-e325-11ce-bfc1-08002be10318}\0005 Primary=1 BitsPerPixel=32 Width=3840 Height=2160 DisplayFlags=0 DisplayFrequency=60 DisplayOrientation=0 PositionX=2560 PositionY=0" "Name=MONITOR\SAM0A59\{4d36e96e-e325-11ce-bfc1-08002be10318}\0007 BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 PositionY=0"
# FOR TESTING Small off, LG on, TV on
./MultiMonitorTool/MultiMonitorTool.exe /LoadConfig .\small-off.cfg
# "C:\Program Files (x86)\Steam\steam.exe" "steam://open/bigpicture"
} elseif ($currentDefaultAudioDevice.name -eq $speakerDevice.name) {
Write-Host "switching to headphone mode"
Set-AudioDevice -ID $headphoneDevice.ID
# Small on, LG on, TV off
# MultiMonitorTool.exe /SetMonitors "Name=MONITOR\GSM5B7F\{4d36e96e-e325-11ce-bfc1-08002be10318}\0011 Primary=1 BitsPerPixel=32 Width=2560 Height=1440 DisplayFlags=0 DisplayFrequency=144 DisplayOrientation=0 PositionX=0 PositionY=0" "Name=MONITOR\SAM0D3B\{4d36e96e-e325-11ce-bfc1-08002be10318}\0005 BitsPerPixel=0 Width=0 Height=0 DisplayFlags=0 DisplayFrequency=0 DisplayOrientation=0 PositionX=0 PositionY=0"
# FOR TESTING Small on, LG off, TV on
./MultiMonitorTool/MultiMonitorTool.exe /LoadConfig .\lg-off.cfg
}