Skip to content

Commit

Permalink
Changing default location for CONFIG_FILE
Browse files Browse the repository at this point in the history
CONFIG_FILE will be looked for in
- ~/.config/auto-selfcontrol/
- /usr/local/etc/auto-selfcontrol/
- $DIR/ (same directory as where Auto-SelfControl has been installed)
If not found, created in ~/.config/auto-selfcontrol/config.json

This will make it easier to backup and sync it across installs.
Answers andreasgrill#58

This will not move an existing config file.
Moving can be done manually to ~/.config/auto-selfcontrol/config.json
(and removing the previous location)
and Auto-selfcontrol will find the new location.
  • Loading branch information
sbibauw committed May 26, 2021
1 parent eba88e6 commit 02f7d98
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions auto-selfcontrol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# Check if auto-selfcontrol was installed through brew and set the config.json location accordingly
if [[ $DIR == /usr/local/* ]]; then
mkdir -p /usr/local/etc/auto-selfcontrol || true
# Check if config file already exists
if [[ -d "~/.config/auto-selfcontrol/" ]]; then
CONFIG_FILE="~/.config/auto-selfcontrol/config.json"
elif [ -f "/usr/local/etc/auto-selfcontrol/config.json" ]; then
CONFIG_FILE="/usr/local/etc/auto-selfcontrol/config.json"
else
elif [ -f "$DIR/config.json" ]; then
CONFIG_FILE="$DIR/config.json"
else
# No config file found: create it in ~/.config/auto-selfcontrol/
mkdir -p "~/.config/auto-selfcontrol/" || true
CONFIG_FILE="~/.config/auto-selfcontrol/config.json"
fi

b=$(tput bold)
Expand Down

0 comments on commit 02f7d98

Please sign in to comment.