diff --git a/config/fetch_script.sh b/config/fetch_script.sh index 0440b7e..a060048 100644 --- a/config/fetch_script.sh +++ b/config/fetch_script.sh @@ -11,7 +11,11 @@ if command_exists lshw; then fi echo "Memory: $(get_used_mem) MiB / $(get_total_mem) MiB" if xhost >& /dev/null ; then - echo "DE/WM: $(get_de_wm)" - echo "Screen Resolution: $(get_screen_resolution)" + if get_de_wm &> /dev/null; then + echo "DE/WM: $(get_de_wm)" + fi + if command_exists xdpyinfo ; then + echo "Screen Resolution: $(get_screen_resolution)" + fi fi diff --git a/config/fetch_script_functions.sh b/config/fetch_script_functions.sh index c539e3c..447148d 100644 --- a/config/fetch_script_functions.sh +++ b/config/fetch_script_functions.sh @@ -51,16 +51,32 @@ get_used_mem() { } get_de_wm() { - if [[ $DESKTOP_SESSION =~ "plasma" ]]; then - echo "KDE Plasma $(plasmashell --version | sed 's/plasmashell //g')" + if ps -e | grep "plasmashell" &> /dev/null ; then + echo "KDE Plasma $(plasmashell --version | awk '{print $2}')" + elif ps -e | grep "gnome-session" &> /dev/null ; then + echo "Gnome $(gnome-shell --version | awk '{print $3}')" + elif ps -e | grep "xfce4-session" &> /dev/null ; then + echo "XFCE $(xfce4-session --version | grep xfce4-session | awk '{print $2}')" + elif ps -e | grep "cinnamon" &> /dev/null ; then + echo "Cinnamon $(cinnamon --version | awk '{print $2}')" + elif ps -e | grep "mate-panel" &> /dev/null ; then + echo "Mate $(mate-about --version | awk '{print $4}')" + elif ps -e | grep "lxsession" &> /dev/null ; then + echo "LXDE" + elif ps -e | grep "sway" &> /dev/null ; then + echo "Sway $(sway --version | awk '{print $2}')" + elif ps -e | grep "icewm-session" &> /dev/null ; then + echo "IceWM $(icewm --version | awk '{print $2}' | sed 's/,//g')" + elif [ ! -z $DESKTOP_SESSION ]; then + echo "$DESKTOP_SESSION" else - echo "$DESKTOP_SESSION" + return 1 fi } get_screen_resolution() { - if xhost >& /dev/null ;then - xdpyinfo | grep dimensions | tr -s ' ' | cut -d " " -f3 + if xhost >& /dev/null && command_exists xdpyinfo; then + xdpyinfo | grep dimensions | tr -s ' ' | cut -d " " -f3 fi }