File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 3
3
4
4
DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null 2>&1 && pwd ) "
5
5
6
- # Check if auto-selfcontrol was installed through brew and set the config.json location accordingly
7
- if [[ $DIR == /usr/local/* ]]; then
8
- mkdir -p /usr/local/etc/auto-selfcontrol || true
6
+ # Check if config file already exists
7
+ if [[ -d " $HOME /.config/auto-selfcontrol/" ]]; then
8
+ CONFIG_FILE=" $HOME /.config/auto-selfcontrol/config.json"
9
+ elif [ -f " /usr/local/etc/auto-selfcontrol/config.json" ]; then
9
10
CONFIG_FILE=" /usr/local/etc/auto-selfcontrol/config.json"
10
- else
11
+ elif [ -f " $DIR /config.json " ] ; then
11
12
CONFIG_FILE=" $DIR /config.json"
13
+ else
14
+ # No config file found: create it in ~/.config/auto-selfcontrol/
15
+ mkdir -p " $HOME /.config/auto-selfcontrol/" || true
16
+ CONFIG_FILE=" $HOME /.config/auto-selfcontrol/config.json"
12
17
fi
13
18
14
19
b=$( tput bold)
Original file line number Diff line number Diff line change 14
14
from pwd import getpwnam
15
15
from optparse import OptionParser
16
16
17
- SETTINGS_DIR = '/usr/local/etc /auto-selfcontrol'
17
+ SETTINGS_DIR = os . path . expanduser ( "~" ) + '/.config /auto-selfcontrol'
18
18
19
19
# Configure global logger
20
20
LOGGER = logging .getLogger ("Auto-SelfControl" )
@@ -51,13 +51,18 @@ def find_config():
51
51
path = os .path .dirname (os .path .realpath (__file__ )))
52
52
global_config_file = "{path}/config.json" .format (
53
53
path = SETTINGS_DIR )
54
+ prev_global_config_file = "{path}/config.json" .format (
55
+ path = '/usr/local/etc/auto-selfcontrol' )
54
56
55
57
if os .path .exists (local_config_file ):
56
58
return local_config_file
57
59
58
60
if os .path .exists (global_config_file ):
59
61
return global_config_file
60
62
63
+ if os .path .exists (prev_global_config_file ):
64
+ return prev_global_config_file
65
+
61
66
exit_with_error (
62
67
"There was no config file found, please create a config file." )
63
68
You can’t perform that action at this time.
0 commit comments