Skip to content

Commit fa6c639

Browse files
committed
Fix Resolution Bug
- Gets the current resolution scale by getting DisplayTransferCharacteristic from WmiMonitorBasicDisplayParams - Divides by 96 to get the scale from the given PPI - ~2x Slower than the current (but broken) implementation w/o PowerShell bottleneck - 34 ms -> 84 ms - ~2.7x Faster than lptstr#131 w/o PowerShell bottleneck - 230 ms
1 parent 72c3403 commit fa6c639

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

winfetch.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,11 @@ function info_uptime {
617617
# ===== RESOLUTION =====
618618
function info_resolution {
619619
Add-Type -AssemblyName System.Windows.Forms
620-
$displays = foreach ($monitor in [System.Windows.Forms.Screen]::AllScreens) {
621-
"$($monitor.Bounds.Size.Width)x$($monitor.Bounds.Size.Height)"
620+
$monitors = [System.Windows.Forms.Screen]::AllScreens
621+
$scale = (Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams -CimSession $cimSession).DisplayTransferCharacteristic / 96
622+
623+
$displays = for($i = 0;$i -lt $monitors.Length;$i++){
624+
"$($monitors[$i].Bounds.Size.Width * $scale[$i])x$($monitors[$i].Bounds.Size.Height * $scale[$i])"
622625
}
623626

624627
return @{

0 commit comments

Comments
 (0)