From c323470f2fbe21fe3b7528a542da5749d27f6e72 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 23 Jan 2020 10:49:47 +0200 Subject: [PATCH] neofetch: Add support for resolution in Wayland and TTY. Closes #1304 and #1301 --- neofetch | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 72813772..4a6288fb 100755 --- a/neofetch +++ b/neofetch @@ -2801,7 +2801,7 @@ get_resolution() { ;; *) - if type -p xrandr >/dev/null; then + if type -p xrandr >/dev/null && [[ $DISPLAY && -z $WAYLAND_DISPLAY ]]; then case $refresh_rate in "on") resolution="$(xrandr --nograb --current |\ @@ -2820,13 +2820,20 @@ get_resolution() { esac resolution="${resolution//\*}" - elif type -p xwininfo >/dev/null; then + elif type -p xwininfo >/dev/null && [[ $DISPLAY && -z $WAYLAND_DISPLAY ]]; then read -r w h \ <<< "$(xwininfo -root | awk -F':' '/Width|Height/ {printf $2}')" resolution="${w}x${h}" - elif type -p xdpyinfo >/dev/null; then + elif type -p xdpyinfo >/dev/null && [[ $DISPLAY && -z $WAYLAND_DISPLAY ]]; then resolution="$(xdpyinfo | awk '/dimensions:/ {printf $2}')" + + elif [[ -d /sys/class/drm ]]; then + for dev in /sys/class/drm/*/modes; do + read -r resolution _ < "$dev" + + [[ $resolution ]] && break + done fi ;; esac