#!/usr/bin/env bash
# This file provide user specific environment used as fallback from several tools

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
  export PATH=$HOME/bin:$PATH
fi

# Search a TERMINAL for i3
for term in kitty termite qterminal urxvt rxvt-unicode sakura gnome-terminal; do
  if [[ -n `which $term` ]]; then
    export TERMINAL=`which $term`
    break
  fi
done

# Pour la batterie des ordinateurs portables (~/bin/battery)
#export BATPATH="/sys/class/power_supply/BAT0"

# Permit DBUS to be launched
if [ "$0" = "/usr/sbin/lightdm-session" -a "$DESKTOP_SESSION" = "i3" ]; then
  export $(gnome-keyring-daemon -s)
fi

# Environnement Pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"

# Démarrage de l'environnement préféré
if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
  case $HOST in
    fuz | fuztest)
      variables_file="${HOME}/.config/environment.d/envvars.conf"
      if [[ -f "${variables_file}" ]]; then
        # charge seulement les lignes sans "#" (non commentées)
        for line in `cat "${variables_file}"|grep -Ev '^#'`; do
          export "$line"
        done
      fi
      exec sway
      ;;
    *)
      : # on ne fait rien, car c'est .xinitrc qui lance i3
      ;;
  esac
fi
# vim: ts=2 sw=2 et nu