#!/bin/sh

# Use the Xorg backend
if test "x$GDK_BACKEND" = "x"; then
    GDK_BACKEND="x11"
fi
export XDG_SESSION_TYPE

# Set $XDG_MENU_PREFIX
if test "x$XDG_MENU_PREFIX" = "x" ; then
    XDG_MENU_PREFIX="gnome-"
fi
export XDG_MENU_PREFIX

# Set $DESKTOP_SESSION
if test "x$DESKTOP_SESSION" = "x" ; then
    DESKTOP_SESSION="budgie-desktop"
fi
export DESKTOP_SESSION

# Set $XDG_CURRENT_DESKTOP
if test "x$XDG_CURRENT_DESKTOP" = "x" ; then
    XDG_CURRENT_DESKTOP="Budgie:GNOME"
fi
export XDG_CURRENT_DESKTOP

# Suppress warning about accessibility bus
#export NO_AT_BRIDGE=1

# Set $XDG_CONFIG_DIRS
if test "x$XDG_CONFIG_DIRS" = "x" ; then
    XDG_CONFIG_DIRS="/usr/local/etc/xdg:/etc/xdg"
fi
export XDG_CONFIG_DIRS

# Set $XDG_DATA_DIRS
if test "x$XDG_DATA_DIRS" = "x" ; then
    XDG_DATA_DIRS="/usr/local/share/gnome:/usr/local/share:/usr/share"
fi
export XDG_DATA_DIRS

# $XDG_CONFIG_HOME defines the base directory relative to which user-specific
# configuration files should be stored. If $XDG_CONFIG_HOME is either not set
# or empty, a default equal to $HOME/.config should be used.
if test "x$XDG_CONFIG_HOME" = "x" ; then
    XDG_CONFIG_HOME=$HOME/.config
fi
[ -d "$XDG_CONFIG_HOME" ] || mkdir "$XDG_CONFIG_HOME"

# $XDG_CACHE_HOME defines the base directory relative to which user-specific
# non-essential data files should be stored. If $XDG_CACHE_HOME is either not
# set or empty, a default equal to $HOME/.cache should be used.
if test "x$XDG_CACHE_HOME" = "x" ; then
    XDG_CACHE_HOME=$HOME/.cache
fi
[ -d "$XDG_CACHE_HOME" ] || mkdir "$XDG_CACHE_HOME"

# $XDG_DATA_HOME defines the base directory relative to which user-specific
# data files should be stored.
if test "x$XDG_DATA_HOME" = "x" ; then
    XDG_DATA_HOME=$HOME/.local/share
fi
[ -d "$XDG_DATA_HOME" ] || mkdir -p "$XDG_DATA_HOME"

# $XDG_STATE_HOME defines the base directory relative to which user-specific
# state files should be stored.
if test "x$XDG_STATE_HOME" = "x" ; then
    XDG_STATE_HOME=$HOME/.local/state
fi
[ -d "$XDG_STATE_HOME" ] || mkdir -p "$XDG_STATE_HOME"

# Unlock gnome-keyring
if test -n "$DESKTOP_SESSION" ; then
    # If .xinitrc is used, uncomment the next line
    #eval $(gnome-keyring-daemon --start --components=pkc11,secrets,ssh)
    export SSH_AUTH_SOCK
fi

# Set up XDG user directores. See
# https://freedesktop.org/wiki/Software/xdg-user-dirs
if command -v xdg-user-dirs-update >/dev/null 2>&1 ; then
    xdg-user-dirs-update
fi
