#!/bin/sh

: ${DOTFILES_HOME:=$HOME/git/dotfiles}

: ${XDG_CACHE_HOME:=$HOME/.cache}
: ${XDG_CONFIG_HOME:=$HOME/.config}
: ${XDG_DATA_HOME:=$HOME/.data}

: ${BIN_HOME:=$HOME/.local/bin}
: ${SV_HOME:=$HOME/.config/sv}
: ${SVDIR:=$HOME/sv}

cat <<! >&2
XDG_CACHE_HOME = ${XDG_CACHE_HOME}
XDG_CONFIG_HOME = ${XDG_CONFIG_HOME}
XDG_DATA_HOME = ${XDG_DATA_HOME}
BIN_HOME = ${BIN_HOME}
SV_HOME = ${SV_HOME}
SVDIR = ${SVDIR}

!

# symlink dirs

ln -sfn "${DOTFILES_HOME}"/.cache "${XDG_CACHE_HOME}"
ln -sfn "${DOTFILES_HOME}"/.config "${XDG_CONFIG_HOME}"
ln -sfn "${DOTFILES_HOME}"/.data "${XDG_DATA_HOME}"
ln -sfn "${DOTFILES_HOME}"/.bin "${BIN_HOME}"
ln -sfn "${DOTFILES_HOME}"/.config/sv "${SV_HOME}"
ln -sfn "${DOTFILES_HOME}"/sv "${SVDIR}"

# symlink files

_ln_home() {
	[ -z "$2" ] && target="$HOME/$1" || target="$HOME/$2"
	source="$PWD/$1"
	ln -sfn "$source" "$target"
}



# environment

echo "${HOME}" >"${XDG_DATA_HOME}"/env/HOME
echo "${XDG_CACHE_HOME}" >"${XDG_DATA_HOME}"/env/XDG_CACHE_HOME
echo "${XDG_CONFIG_HOME}" >"${XDG_DATA_HOME}"/env/XDG_CONFIG_HOME
echo "${XDG_DATA_HOME}" >"${XDG_DATA_HOME}"/env/XDG_DATA_HOME
echo "${SVDIR}" >"${SVDIR}"/env/SVDIR

# gnome

for i in $(seq 1 9); do gsettings set org.gnome.shell.keybindings switch-to-application-$i []; done

