58 lines
1.6 KiB
Bash
Executable file
58 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# "Automate" flipping applications between light and dark themes.
|
|
|
|
DOTFILES="$(cd "$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")" && pwd)"
|
|
SCHEME_FILE="${DOTFILES}/.color-scheme"
|
|
OSTYPE="$(uname -s)"
|
|
|
|
install_dark() {
|
|
ln -sf "${DOTFILES}/alacritty/colors-dark.yml" "${DOTFILES}/alacritty/colors.yml"
|
|
ln -sf "${DOTFILES}/task/jdkaplan-dark.theme" "${DOTFILES}/task/color.theme"
|
|
ln -sf "${DOTFILES}/vim/colors/jdkaplan-dark.vim" "${DOTFILES}/vim/colors/jdkaplan.vim"
|
|
|
|
if [ "${OSTYPE}" == 'Linux' ]; then
|
|
ln -sf "${DOTFILES}/xsettingsd/xsettingsd-dark.conf" "${DOTFILES}/xsettingsd/xsettingsd.conf"
|
|
fi
|
|
}
|
|
|
|
install_light() {
|
|
ln -sf "${DOTFILES}/alacritty/colors-light.yml" "${DOTFILES}/alacritty/colors.yml"
|
|
ln -sf "${DOTFILES}/task/jdkaplan-light.theme" "${DOTFILES}/task/color.theme"
|
|
ln -sf "${DOTFILES}/vim/colors/jdkaplan-light.vim" "${DOTFILES}/vim/colors/jdkaplan.vim"
|
|
|
|
if [ "${OSTYPE}" == 'Linux' ]; then
|
|
ln -sf "${DOTFILES}/xsettingsd/xsettingsd-light.conf" "${DOTFILES}/xsettingsd/xsettingsd.conf"
|
|
fi
|
|
}
|
|
|
|
postinstall() {
|
|
"${DOTFILES}/alacritty/install"
|
|
|
|
if [ "${OSTYPE}" == 'Linux' ] && [ "${XDG_SESSION_TYPE-}" != 'wayland' ]; then
|
|
killall --signal HUP xsettingsd
|
|
fi
|
|
}
|
|
|
|
if [ -f "${SCHEME_FILE}" ]; then
|
|
default_scheme="$(head -n 1 "${SCHEME_FILE}")"
|
|
else
|
|
default_scheme='dark'
|
|
fi
|
|
|
|
scheme="${1:-${default_scheme}}"
|
|
|
|
if [ "${scheme}" = 'dark' ]; then
|
|
install_dark
|
|
elif [ "${scheme}" = 'light' ]; then
|
|
install_light
|
|
else
|
|
echo "Unknown color scheme: ${scheme}"
|
|
exit 1
|
|
fi
|
|
|
|
postinstall
|
|
|
|
echo "$scheme" > "${SCHEME_FILE}"
|