1
0
Fork 0
dotfiles/bin/set-colors
Jeremy Kaplan 71d8737447 neovim: Convert all config to Lua
I've been using this with only minimal changes for a few weeks now, so
this seems like a good place to checkpoint it.
2023-05-21 16:11:44 -07:00

70 lines
2.2 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}/bat/config-dark" "${DOTFILES}/bat/config"
ln -sf "${DOTFILES}/task/jdkaplan-dark.theme" "${DOTFILES}/task/color.theme"
ln -sf "${DOTFILES}/vim/colors/jdkaplan-dark.vim" "${DOTFILES}/vim/colors/jdkaplan.vim"
ln -sf "${DOTFILES}/neovim/colors/jdkaplan-cool.lua" "${DOTFILES}/neovim/colors/jdkaplan-temp.lua"
if [ "${OSTYPE}" == 'Linux' ]; then
ln -sf "${DOTFILES}/xsettingsd/xsettingsd-dark.conf" "${DOTFILES}/xsettingsd/xsettingsd.conf"
fi
if [ "${XDG_SESSION_TYPE-}" == 'wayland' ]; then
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita:dark'
fi
}
install_light() {
ln -sf "${DOTFILES}/alacritty/colors-light.yml" "${DOTFILES}/alacritty/colors.yml"
ln -sf "${DOTFILES}/bat/config-light" "${DOTFILES}/bat/config"
ln -sf "${DOTFILES}/task/jdkaplan-light.theme" "${DOTFILES}/task/color.theme"
ln -sf "${DOTFILES}/vim/colors/jdkaplan-light.vim" "${DOTFILES}/vim/colors/jdkaplan.vim"
ln -sf "${DOTFILES}/neovim/colors/jdkaplan-warm.lua" "${DOTFILES}/neovim/colors/jdkaplan-temp.lua"
if [ "${OSTYPE}" == 'Linux' ]; then
ln -sf "${DOTFILES}/xsettingsd/xsettingsd-light.conf" "${DOTFILES}/xsettingsd/xsettingsd.conf"
fi
if [ "${XDG_SESSION_TYPE-}" == 'wayland' ]; then
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'
fi
}
postinstall() {
"${DOTFILES}/alacritty/install"
if [ "${OSTYPE}" == 'Linux' ]; 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}"