#!/bin/sh

set -a
#. "/etc/profile"
. "$HOME/.config/user-dirs.dirs"
. "$XDG_CONFIG_HOME/locale.conf"
set +a

export ANDROID_SDK_ROOT='/opt/android-sdk'
export AUTOSTART_DISPLAY=''

export BEMENU_OPTS="--tb '#6272a4'\
 --tf '#f8f8f2'\
 --fb '#282a36'\
 --ff '#f8f8f2'\
 --nb '#282a36'\
 --nf '#6272a4'\
 --hb '#44475a'\
 --hf '#50fa7b'\
 --sb '#44475a'\
 --sf '#50fa7b'\
 --scb '#282a36'\
 --scf '#ff79c6'\
 --list 25 --ignorecase -p ''"

export DMENU="bemenu"
export DOCKER_BUILDKIT=1
export DRONE_SERVER='https://ci.serguzim.me'

_editor="$(which vim)"
[ -x "$(command -v nvim)" ] && _editor="$(which nvim)"
export EDITOR="$_editor"

export GOPATH="$XDG_DATA_HOME/go"

_hostname=$(cat /proc/sys/kernel/hostname)
export HOSTNAME="$_hostname"

export KUBECONFIG="$HOME/.kube/config"

#export LOCALE_ARCHIVE="/usr/lib/locale/locale-archive"

export MAILCAPS="$XDG_CONFIG_HOME/mailcap/mailcaprc"
_makeflags=$(grep -c ^processor /proc/cpuinfo)
export MAKEFLAGS="-j$_makeflags"
export MARKPATH="$XDG_CONFIG_HOME/zsh/jump_marks"
export MOAR="--style=dracula"

_whoami=$(whoami)
export NIX_PATH="$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/$_whoami/channels${NIX_PATH:+:$NIX_PATH}"
export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config"

export OPENFAAS_URL="https://faas.serguzim.me"
export OSH="$XDG_CONFIG_HOME/bash/oh-my-bash"

export PASSWORD_STORE_GENERATED_LENGTH='64'
# add my paths
export PATH="$HOME/.local/bin:$HOME/.bin:$PATH"
# add tool paths
export PATH="$GOPATH/bin:$HOME/.cargo/bin:$HOME/.local/share/JetBrains/Toolbox/scripts:$PATH"
export PS1='\$ '

#export QT_QPA_PLATFORM="wayland;xcb"
export QT_QPA_PLATFORM="xcb"
export QT_QPA_PLATFORMTHEME="qt5ct"

#export SDL_VIDEODRIVER="wayland"

export TERMINAL="alacritty"
export TIME_STYLE="long-iso"

export VIMINIT="if has('nvim') | source $XDG_CONFIG_HOME/nvim/init.lua | else | source $XDG_CONFIG_HOME/vim/vimrc | endif"

export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime"
export WOODPECKER_SERVER="https://ci.serguzim.me"

export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
export ZSH="$ZDOTDIR/oh-my-zsh"

### conditionals

# shellcheck disable=2089
[ -x "$(command -v bat)" ] && export MANPAGER="sh -c 'col -bx | bat -l man -p'"
# shellcheck disable=2090
[ -x "$(command -v moar)" ] && export MANPAGER="moar"
[ -x "$(command -v moar)" ] && export PAGER="moar"

[ -x "$(command -v gpgconf)" ] && export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)

[ -x "$(command -v home-manager)" ] \
	&& [ -x "$(command -v nix)" ] \
	&& [ -f "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ] \
	&& . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"

[ -f "$HOME/.config/environment.local" ] && . "$HOME/.config/environment.local"