From a51003e89f247f1e250472ac353be8de25c19c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 4 Mar 2024 12:10:57 +0100 Subject: [PATCH] WIP: attempt to detect DE on remote sessions When connecting with ssh to a machine that has an X11 session running, try to find which DISPLAY we can query. It only detects the DE for now. --- neofetch | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 48b96d21..016204ab 100755 --- a/neofetch +++ b/neofetch @@ -1833,7 +1833,7 @@ get_de() { # the desktop variables are sometimes also set to the # window manager name. This checks to see if WM == DE # and discards the DE value. - [[ $de == "$wm" ]] && { unset -v de; return; } + [[ -n "$wm" && ( $de == "$wm" ) ]] && { unset -v de; return; } ;; esac @@ -1841,9 +1841,19 @@ get_de() { [[ $DISPLAY && -z $de ]] && type -p xprop &>/dev/null && \ de=$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/') + # Fallback to exploring displays with xprop for remote sessions. + if [[ -z $DISPLAY && -z $de ]]; then + for display in `seq 0 9`; do + type -p xprop &>/dev/null && \ + de=$(xprop -display ":$display" -root | awk '/KDE_SESSION_VERSION|_KDE_NET_WM_|^_MUFFIN|xfce4|xfce5/') + [[ -n "$de" ]] && break + done + fi + # Format strings. case $de in KDE_SESSION_VERSION*) de=KDE${de/* = } ;; + *_KDE_NET_WM_*) de=KDE ;; *xfce4*) de=Xfce4 ;; *xfce5*) de=Xfce5 ;; *xfce*) de=Xfce ;;