@@ -3079,7 +3079,34 @@ get_resolution() {
30793079 ;;
30803080
30813081 * )
3082- if type -p xrandr > /dev/null && [[ $DISPLAY && -z $WAYLAND_DISPLAY ]]; then
3082+ if type -p wayland-info > /dev/null && [[ $WAYLAND_DISPLAY ]]; then
3083+ resolution=" "
3084+ # `wayland-info` prints one interface per display
3085+ num_displays=" $( wayland-info -i wl_output | csplit - ' /interface: /' ' {*}' --suppress-matched -z -n 1 --prefix ' /tmp/neofetch-wayland-info-display-' | wc -l) "
3086+ for (( display= 0 ; display< $num_displays ; display++ )) ; do
3087+ scale_factor=" $( grep -Po ' scale: \K\d+' < /tmp/neofetch-wayland-info-display-$display ) "
3088+ # `wayland-info` prints all modes supported by the display, and current mode is flagged as `current`
3089+ mode=" $( grep ' flags: .*current' -B1 < /tmp/neofetch-wayland-info-display-$display | head -1) "
3090+ # width: 3456 px, height: 2160 px, refresh: 59.996 Hz,
3091+ width=" $( echo $mode | grep -Po ' width: \K\d+' ) "
3092+ height=" $( echo $mode | grep -Po ' height: \K\d+' ) "
3093+ if [[ $scale_factor -gt 1 ]]; then
3094+ (( width= width/ scale_factor))
3095+ (( height= height/ scale_factor ))
3096+ resolution=" $resolution ${width} x${height} @${scale_factor} x"
3097+ else
3098+ resolution=" $resolution ${width} x${height} "
3099+ fi ;
3100+
3101+ if [[ " $refresh_rate " == " on" ]]; then
3102+ refresh=" $( echo $mode | grep -Po ' refresh: \K[\d\.]+' ) "
3103+ [[ $refresh ]] && resolution=" $resolution @ $refresh Hz"
3104+ fi
3105+
3106+ resolution=" $resolution , "
3107+ done
3108+ rm /tmp/neofetch-wayland-info-display-*
3109+ elif type -p xrandr > /dev/null && [[ $DISPLAY && -z $WAYLAND_DISPLAY ]]; then
30833110 case $refresh_rate in
30843111 " on" )
30853112 resolution=" $( xrandr --nograb --current | \
0 commit comments