#!/bin/bash

set -x

touch /tmp/xstartup-run

# This lets shells run my bashrc
unset DRS_BASHRC_RUN

# This hopefully makes dconf use ~/.cache instead of /run/**
unset XDG_RUNTIME_DIR

# which_graphical_environment=fvwm2
which_graphical_environment=mate

# This helps with squinty fonts for QT applications.
# export QT_AUTO_SCREEN_SCALE_FACTOR=1.5
export QT_AUTO_SCREEN_SCALE_FACTOR=0
export QT_SCALE_FACTOR=1.5

case "$(hostname)" in
    @uspubl-drs004)
        which_graphical_environment=fvwm2
        ;;
    connserv)
        which_graphical_environment=mate
        ;;
    zareason2|tp-ppro)
        # cinnamon crashed on Debian 10.9 with TightVNC
        which_graphical_environment=xfce4-session
        ;;
    *)
        # We don't error on no match for this one, so we can default
        # to cinnamon
        ;;
esac
        
case "$which_graphical_environment" in
    fvwm2)
        # This appears to help with cut and paste with TigerVNC.
        # vncconfig -nowin &
        # This does it for TightVNC.
        autocutsel -s CLIPBOARD -fork

        fvwm2 &

        terminal-window
        ;;
    mate)
        autocutsel -s CLIPBOARD -fork

        mate-session
        ;;
    cinnamon)
        cinnamon-session
        ;;
	xfce4-session)
		xfce4-session
		;;
    *)
        (
            echo "$0: \$which_graphical_environment has a strange value:"
            echo "$which_graphical_environment"
        ) 1>&2
        exit 1
        ;;
esac