sudo apt install xfce4
cd ~
nano .bashrc
export DISPLAY=:0.0
xfce4-session
if pgrep -x "gedit" > /dev/null
then
echo "Running"
else
xfce4-session
fi
if ! pgrep -x "xfce4-session" > /dev/null
then
xfce4-session
fi
P.S. Running command xfce4-session should be avoided. One should run startxfce4 instead.