summarylogtreecommitdiffstats
path: root/xdg_config_dirs.patch
blob: ba0d723475ef9bbc0273e96a7114ae22414bf3ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--- src/gam/var.py	2020-05-14 08:28:44.595484330 -0700
+++ src/gam/var.py	2020-05-14 08:30:42.780304096 -0700
@@ -22,6 +22,19 @@
 GAM_LATEST_RELEASE = GAM_ALL_RELEASES + '/latest'
 GAM_PROJECT_FILEPATH = 'https://raw.githubusercontent.com/jay0lee/GAM/master/src/'
 
+try:
+    XDG_CONFIG_DIR = os.environ['XDG_CONFIG_HOME']
+except KeyError:
+    XDG_CONFIG_DIR = os.path.expanduser("~") + '/.config/'
+CONFIG_DIR = XDG_CONFIG_DIR + 'gam/'
+
+try:
+    os.makedirs(CONFIG_DIR, mode=700)
+except OSError:
+    if not os.path.isdir(CONFIG_DIR):
+        raise
+
+
 true_values = ['on', 'yes', 'enabled', 'true', '1']
 false_values = ['off', 'no', 'disabled', 'false', '0']
 usergroup_types = [
@@ -36,8 +49,8 @@
 WARNING_PREFIX = 'WARNING: '
 UTF8 = 'utf-8'
 UTF8_SIG = 'utf-8-sig'
-FN_EXTRA_ARGS_TXT = 'extra-args.txt'
-FN_LAST_UPDATE_CHECK_TXT = 'lastupdatecheck.txt'
+FN_EXTRA_ARGS_TXT = CONFIG_DIR + 'extra-args.txt'
+FN_LAST_UPDATE_CHECK_TXT = CONFIG_DIR + 'lastupdatecheck.txt'
 MY_CUSTOMER = 'my_customer'
 # See https://support.google.com/drive/answer/37603
 MAX_GOOGLE_SHEET_CELLS = 5000000
@@ -1071,9 +1084,9 @@
 
 #
 _DEFAULT_CHARSET = UTF8
-_FN_CLIENT_SECRETS_JSON = 'client_secrets.json'
-_FN_OAUTH2SERVICE_JSON = 'oauth2service.json'
-_FN_OAUTH2_TXT = 'oauth2.txt'
+_FN_CLIENT_SECRETS_JSON = CONFIG_DIR + 'client_secrets.json'
+_FN_OAUTH2SERVICE_JSON = CONFIG_DIR + 'oauth2service.json'
+_FN_OAUTH2_TXT = CONFIG_DIR + 'oauth2.txt'
 #
 GM_Globals = {
     GM_SYSEXITRC: 0,
@@ -1119,7 +1132,7 @@
 GC_CLIENT_SECRETS_JSON = 'client_secrets_json'
 # GAM config directory containing client_secrets.json, oauth2.txt,
 # oauth2service.json, extra_args.txt
-GC_CONFIG_DIR = 'config_dir'
+GC_CONFIG_DIR = CONFIG_DIR
 # custmerId from gam.cfg or retrieved from Google
 GC_CUSTOMER_ID = 'customer_id'
 # If debug_level > 0: extra_args[u'prettyPrint'] = True,