From fa6c6399f13dbba56829ce472a5d33029ae4f866 Mon Sep 17 00:00:00 2001 From: Carterpersall Date: Tue, 20 Sep 2022 13:06:55 -0500 Subject: [PATCH] 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 #131 w/o PowerShell bottleneck - 230 ms --- winfetch.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/winfetch.ps1 b/winfetch.ps1 index aadf9ac..8b81ee5 100644 --- a/winfetch.ps1 +++ b/winfetch.ps1 @@ -617,8 +617,11 @@ function info_uptime { # ===== RESOLUTION ===== function info_resolution { Add-Type -AssemblyName System.Windows.Forms - $displays = foreach ($monitor in [System.Windows.Forms.Screen]::AllScreens) { - "$($monitor.Bounds.Size.Width)x$($monitor.Bounds.Size.Height)" + $monitors = [System.Windows.Forms.Screen]::AllScreens + $scale = (Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams -CimSession $cimSession).DisplayTransferCharacteristic / 96 + + $displays = for($i = 0;$i -lt $monitors.Length;$i++){ + "$($monitors[$i].Bounds.Size.Width * $scale[$i])x$($monitors[$i].Bounds.Size.Height * $scale[$i])" } return @{