Skip to content

Commit afcf53f

Browse files
[PR] dylanaraps/neofetch#2356 from CarterLi - Resolution (macOS): improve detection
Upstream PR: dylanaraps/neofetch#2356 Thanks to @CarterLi Co-authored-by: 李通洲 <zhangsongcui3371@sina.com>
2 parents 10b227a + c505323 commit afcf53f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

neofetch

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,10 +3863,16 @@ get_resolution() {
38633863
if spdisplays_resolution="$(PlistBuddy -c "print 0:_items:${gpu}:spdisplays_ndrvs:${display}:_spdisplays_resolution" $temp_plist)" 2>/dev/null; then
38643864
spdisplays_resolution="${spdisplays_resolution//.[0-9][0-9]/}"
38653865
if spdisplays_pixels="$(PlistBuddy -c "print 0:_items:${gpu}:spdisplays_ndrvs:${display}:_spdisplays_pixels" $temp_plist)" 2>/dev/null; then
3866-
scaled_x="$(echo "$spdisplays_resolution" | awk '{print $1}')"
3867-
output_x="$(echo "$spdisplays_pixels" | awk '{print $1}')"
3868-
(( scale_factor=output_x/scaled_x ))
3869-
[[ $scale_factor -gt 1 ]] && spdisplays_resolution="${spdisplays_resolution// @/ @${scale_factor}x @}"
3866+
scaled_x="$(echo "$spdisplays_resolution" | awk '{print $1}')"
3867+
output_x="$(echo "$spdisplays_pixels" | awk '{print $1}')"
3868+
(( scale_factor=output_x/scaled_x ))
3869+
if [[ $scale_factor -gt 1 ]]; then
3870+
if [[ "$spdisplays_resolution" == *"@"* ]]; then
3871+
spdisplays_resolution="${spdisplays_resolution// @/ @${scale_factor}x @}"
3872+
else
3873+
spdisplays_resolution="${spdisplays_resolution} @ ${scale_factor}x"
3874+
fi
3875+
fi
38703876
fi
38713877
spdisplays_resolution="${spdisplays_resolution// x /x}"
38723878
[[ $gpu -gt 0 || $display -gt 0 ]] && resolution+=", "

0 commit comments

Comments
 (0)