diff --git a/.gitignore b/.gitignore index 97089ae..9b0069a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.swp .profiles +.color-scheme diff --git a/bin/set-colors b/bin/set-colors index 2e26146..ccfd402 100755 --- a/bin/set-colors +++ b/bin/set-colors @@ -1,21 +1,32 @@ #!/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" -scheme="${1:-dark}" +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 ln -sf "${DOTFILES}/alacritty/colors-dark.yml" "${DOTFILES}/alacritty/colors.yml" ln -sf "${DOTFILES}/vim/colors/jdkaplan-dark.vim" "${DOTFILES}/vim/colors/jdkaplan.vim" ln -sf "${DOTFILES}/task/jdkaplan-dark.theme" "${DOTFILES}/task/color.theme" "${DOTFILES}/alacritty/install" + echo "$scheme" > "${SCHEME_FILE}" elif [ "${scheme}" = 'light' ]; then ln -sf "${DOTFILES}/alacritty/colors-light.yml" "${DOTFILES}/alacritty/colors.yml" ln -sf "${DOTFILES}/vim/colors/jdkaplan-light.vim" "${DOTFILES}/vim/colors/jdkaplan.vim" ln -sf "${DOTFILES}/task/jdkaplan-light.theme" "${DOTFILES}/task/color.theme" "${DOTFILES}/alacritty/install" + echo "$scheme" > "${SCHEME_FILE}" else echo "Unknown color scheme: ${scheme}" exit 1 diff --git a/default.conf.yaml b/default.conf.yaml index 0cd033d..5107911 100644 --- a/default.conf.yaml +++ b/default.conf.yaml @@ -2,7 +2,7 @@ - mkdir -p ~/.config - mkdir -p ~/.config/direnv - mkdir -p ~/.task - - ./bin/set-colors dark + - ./bin/set-colors - clean: ['~', '~/.config']