Skip to content

Commit 15d2292

Browse files
Merge pull request #283 from jotopo/feature/update-community-scripts
Update the community scripts.
2 parents 44e1999 + 0318e53 commit 15d2292

9 files changed

+189
-224
lines changed

Community Scripts/HDRswitch-VDD.ps1

+5-15
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,13 @@ if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
77
}
88
}
99

10-
$repoName = "PSGallery"
11-
$moduleName1 = "DisplayConfig"
12-
$moduleName2 = "MonitorConfig"
13-
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
14-
& .\dep_fix.ps1
15-
}
10+
# Install dependencies if required
11+
. "$PSScriptRoot\set-dependencies.ps1"
1612

17-
# Import the local module
18-
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
19-
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue
13+
# Getting the correct display
14+
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
2015

21-
# Import the other localmodule
22-
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
23-
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue
24-
25-
$disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
26-
$bpcc = Get-DisplayColorInfo -DisplayId $disp | Select-Object BitsPerColorChannel | Select-Object -ExpandProperty BitsPerColorChannel
16+
$bpcc = Get-DisplayColorInfo -DisplayId $disp.DisplayId | Select-Object BitsPerColorChannel | Select-Object -ExpandProperty BitsPerColorChannel
2717

2818
if ( $bpcc -is [int] ) {
2919
if ( $bpcc -gt 8 ) {

Community Scripts/changeres-VDD.ps1

+19-31
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
1+
param(
2+
[Parameter(Mandatory, Position=0)]
3+
[Alias("X","HorizontalResolution")]
4+
[int]$xres,
5+
[Parameter(Mandatory, Position=1)]
6+
[Alias("Y","VerticalResolution")]
7+
[int]$yres
8+
)
9+
110
# Self-elevate the script if required
211
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
312
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
4-
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
5-
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
6-
Exit
13+
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
14+
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
15+
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
16+
exit
717
}
818
}
919

10-
$repoName = "PSGallery"
11-
$moduleName1 = "DisplayConfig"
12-
$moduleName2 = "MonitorConfig"
13-
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
14-
& .\dep_fix.ps1
15-
}
16-
20+
# Install dependencies if required
21+
. "$PSScriptRoot\set-dependencies.ps1"
1722

18-
# Import the local module
19-
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
20-
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
23+
# Getting the correct display
24+
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
2125

22-
# Import the other localmodule
23-
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
24-
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
25-
26-
# Check if there are enough arguments
27-
$numArgs = $args.Count
28-
switch ($numArgs) {
29-
0 { Write-Error "This script requires at least 2 arguments Xres Yres."; break }
30-
1 { Write-Error "This script requires at least 2 arguments Xres Yres."; break }
31-
2 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
32-
$vres = $args[0]
33-
$hres = $args[1]
34-
continue
35-
}
36-
default { Write-Error "Invalid number of arguments: $numArgs"; break }
37-
}
38-
# Setting the resolution on the correct display.
39-
Get-DisplayConfig | Set-DisplayResolution -DisplayId $disp -Width $vres -Height $hres | Use-DisplayConfig
26+
# Setting the resolution on the display
27+
Set-DisplayResolution -DisplayId $disp.DisplayId -Width $xres -Height $yres

Community Scripts/dep_fix.ps1

-32
This file was deleted.

Community Scripts/primary-VDD.ps1

+4-15
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,9 @@ if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
77
}
88
}
99

10-
$repoName = "PSGallery"
11-
$moduleName1 = "DisplayConfig"
12-
$moduleName2 = "MonitorConfig"
13-
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
14-
& .\dep_fix.ps1
15-
}
16-
17-
18-
# Import the local module
19-
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path; import-module -name $dpth
10+
# Install dependencies if required
11+
. "$PSScriptRoot\set-dependencies.ps1"
2012

21-
# Import the other localmodule
22-
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path; import-module -name $mpth
13+
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
2314

24-
25-
$disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
26-
Set-DisplayPrimary -DisplayId $disp
15+
Set-DisplayPrimary -DisplayId $disp.DisplayId

Community Scripts/refreshrate-VDD.ps1

+26-31
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1+
param(
2+
[Parameter(Mandatory, Position = 0)]
3+
[ValidateSet(
4+
30,
5+
60,
6+
75,
7+
90,
8+
120,
9+
144,
10+
165,
11+
240,
12+
480,
13+
500)]
14+
[int]$refreshrate
15+
)
16+
117
# Self-elevate the script if required
218
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
319
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
4-
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
5-
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
6-
Exit
20+
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
21+
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
22+
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
23+
exit
724
}
825
}
926

10-
$repoName = "PSGallery"
11-
$moduleName1 = "DisplayConfig"
12-
$moduleName2 = "MonitorConfig"
13-
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
14-
& .\dep_fix.ps1
15-
}
16-
27+
# install dependencies if required
28+
. "$PSScriptRoot\set-dependencies.ps1"
1729

18-
# Import the local module
19-
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
20-
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
30+
# Getting the correct display
31+
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
2132

22-
# Import the other localmodule
23-
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
24-
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
25-
26-
27-
# Use the module's functions and cmdlets in your script
28-
# Check if there are enough arguments
29-
$numArgs = $args.Count
30-
switch ($numArgs) {
31-
0 { Write-Error "This script requires a refreshrate above 59 or reset"; break }
32-
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
33-
$rate = $args[0]
34-
continue
35-
}
36-
default { Write-Error "Invalid number of arguments: $numArgs"; break }
37-
}
38-
# Setting the resolution on the correct display.
39-
Get-DisplayConfig | Set-DisplayRefreshRate -DisplayId $disp -RefreshRate $rate | Use-DisplayConfig
33+
# Setting the refresh rate on the correct display.
34+
Set-DisplayRefreshRate -DisplayId $disp.DisplayId -RefreshRate $rate

Community Scripts/rotate-VDD.ps1

+31-35
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,42 @@
1+
param(
2+
[Parameter(Mandatory, Position = 0)]
3+
[ValidateSet(90, 180, 270)]
4+
[int]$rotate
5+
)
6+
17
# Self-elevate the script if required
28
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
39
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
4-
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
5-
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
6-
Exit
10+
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
11+
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
12+
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
13+
exit
714
}
815
}
916

10-
$repoName = "PSGallery"
11-
$moduleName1 = "DisplayConfig"
12-
$moduleName2 = "MonitorConfig"
13-
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
14-
& .\dep_fix.ps1
15-
}
17+
# install dependencies if required.
18+
. "$PSScriptRoot\set-dependencies.ps1"
1619

20+
switch ($rotate) {
21+
90 {
22+
$degree = "Rotate90"
23+
continue
24+
}
25+
180 {
26+
$degree = "Rotate180"
27+
continue
28+
}
29+
270 {
30+
$degree = "Rotate270"
31+
continue
32+
}
33+
default { Write-Error "Invalid rotation angle(valid 90,180,270)."; break }
34+
}
1735

18-
# Import the local module
19-
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
20-
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
2136

22-
# Import the other localmodule
23-
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
24-
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
37+
# Getting the correct display
38+
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
2539

26-
# Check if there are enough arguments
27-
$numArgs = $args.Count
28-
switch ($numArgs) {
29-
0 { Write-Error "This script requires at least 1, rotation in degrees ex. 90/180/270."; break }
30-
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
31-
switch ($args[0]) {
32-
90 { $degree = "Rotate90"
33-
continue
34-
}
35-
180 { $degree = "Rotate180"
36-
continue
37-
}
38-
270 { $degree = "Rotate270"
39-
continue
40-
}
41-
default { Write-Error "Invalid rotation angle(valid 90,180,270)."; break }
42-
}
43-
default { Write-Error "Invalid number of arguments: $numArgs"; break }
44-
}
4540
# Setting the resolution on the correct display.
46-
Get-DisplayConfig | Set-DisplayRotation -DisplayId $disp -Rotation $degree | Use-DisplayConfig
41+
Set-DisplayRotation -DisplayId $disp.DisplayId -Rotation $degree
42+

Community Scripts/scale-VDD.ps1

+34-46
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,42 @@
1+
[CmdletBinding(DefaultParameterSetName = "UserDefined")]
2+
param(
3+
[Parameter(Mandatory, Position = 0, ParameterSetName = "UserDefined")]
4+
[ValidateSet("100", "125", "150", "175", "200", "225", "250", "300", "350", "400", "450", "500")]
5+
[int]$scale,
6+
7+
[Parameter(Mandatory, ParameterSetName = "Recommended")]
8+
[switch]$reset
9+
)
10+
111
# Self-elevate the script if required
212
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
3-
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
4-
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
5-
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
6-
Exit
7-
}
8-
}
9-
10-
$repoName = "PSGallery"
11-
$moduleName1 = "DisplayConfig"
12-
$moduleName2 = "MonitorConfig"
13-
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
14-
& .\dep_fix.ps1
13+
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
14+
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
15+
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
16+
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
17+
exit
18+
}
1519
}
1620

21+
# Install dependencies if required.
22+
. "$PSScriptRoot\set-dependencies.ps1"
1723

18-
# Import the local module
19-
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
20-
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
24+
# Getting the correct display
25+
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
2126

22-
# Import the other localmodule
23-
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
24-
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
25-
26-
# Check if there are enough arguments
27-
$numArgs = $args.Count
28-
switch ($numArgs) {
29-
0 { Write-Error "This script requires a scale 'reset' or an accepted percfentage value (100, 125, 150, 175, 200, 225, 250, 300, 350, 400, 450, 500) limited by the device max scale."; break }
30-
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
31-
$maxscale = Get-DisplayScale -DisplayId $disp | Select-Object -ExpandProperty MaxScale
32-
if ( $args[0] -is [int] ) {
33-
if ( $args[0] -le $maxscale -And $args[0] -ge 100 ) {
34-
Set-DisplayScale -DisplayId $disp -Scale $args[0]
35-
break
36-
}
37-
else {
38-
Write-Error "Invalid scale percentage."
39-
break
40-
}
41-
}
42-
else {
43-
if ( $args[0] -eq "reset" ) {
44-
Set-DisplayScale -DisplayId $disp -Recommended
45-
break
46-
}
47-
else {
48-
Write-Error "Invalid arguments: 'reset' or a valid percentage value like 150 is acceptable."
49-
break
50-
}
51-
}
27+
$maxscale = Get-DisplayScale -DisplayId $disp.DisplayId | Select-Object -ExpandProperty MaxScale
28+
if ( $PSCmdlet.ParameterSetName -eq "UserDefined" ) {
29+
Write-Host "Setting scale to $scale"
30+
if ( $scale -le $maxscale ) {
31+
Set-DisplayScale -DisplayId $disp.DisplayId -Scale $scale
32+
}
33+
else {
34+
Write-Error "Scale percentage $scale is higher than max scale $maxscale"
5235
}
53-
default { Write-Error "Invalid number of arguments: $numArgs"; break }
36+
}
37+
elseif ( $PSCmdlet.ParameterSetName -eq "Recommended" ) {
38+
Set-DisplayScale -DisplayId $disp.DisplayId -Recommended
39+
}
40+
else {
41+
Write-Error "Invalid arguments: 'reset' or a valid percentage value like 150 is acceptable."
5442
}

0 commit comments

Comments
 (0)