#!/bin/sh

if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile" ]; then
	. "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile"
else
	. "$HOME/.xprofile"
fi

if [ -f /etc/hostname ]; then
	HOST=$(cat /etc/hostname)
else
	HOST=$(hostname)
fi

if [ "$HOST" = "archmetabox" ] ; then
	# this is specifically for the laptop so check hostname
	xrandr --setprovideroutputsource modesetting NVIDIA-G0
	xrandr --auto
fi

# start gnome keyring to, used to be done by login manager.
eval "$(gnome-keyring-daemon --start)"
export SSH_AUTH_SOCK

# My default is still xmonad, maybe dwm in future?
session=${1:-xmonad}

case $session in
    i3|i3wm)
	    exec i3;;
    dwm)
	    dwmblocks &
	    exec dwm;;
    xmonad)
	    exec "$HOME/.xmonad/start-xmonad.sh";;
    # No known session, try to run it as command
    *)
    exec twm;;
esac
