aboutsummaryrefslogtreecommitdiffstats
path: root/testing/mycroft-core/0003-xdg.patch
blob: d041b6f9389fcb2ff95248b6087fb2375e06ce07 (plain) (blame)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
Upstream pull-request: https://github.com/MycroftAI/mycroft-core/pull/2578

diff --git a/README.md b/README.md
index 1665b0a68dd..eaf04259ddb 100644
--- a/README.md
+++ b/README.md
@@ -71,20 +71,20 @@ Mycroft is nothing without skills.  There are a handful of default skills that a
 
 ## Pairing Information
 Pairing information generated by registering with Home is stored in:
-`~/.mycroft/identity/identity2.json` <b><-- DO NOT SHARE THIS WITH OTHERS!</b>
+`~/.config/mycroft/identity/identity2.json` <b><-- DO NOT SHARE THIS WITH OTHERS!</b>
 
 ## Configuration
 Mycroft configuration consists of 4 possible locations:
-- `mycroft-core/mycroft/configuration/mycroft.conf`(Defaults)
+- `mycroft-core/mycroft/configuration/mycroft.conf` (Defaults)
 - [Mycroft Home](https://home.mycroft.ai) (Remote)
-- `/etc/mycroft/mycroft.conf`(Machine)
-- `$HOME/.mycroft/mycroft.conf`(User)
+- `/etc/mycroft/mycroft.conf` (Machine)
+- `$XDG_CONFIG_DIR/mycroft/mycroft.conf` (which is by default `$HOME/.config/mycroft/mycroft.conf`) (USER)
 
 When the configuration loader starts, it looks in these locations in this order, and loads ALL configurations. Keys that exist in multiple configuration files will be overridden by the last file to contain the value. This process results in a minimal amount being written for a specific device and user, without modifying default distribution files.
 
 ## Using Mycroft Without Home
 
-If you do not wish to use the Mycroft Home service, before starting Mycroft for the first time, create `$HOME/.mycroft/mycroft.conf` with the following contents:
+If you do not wish to use the Mycroft Home service, before starting Mycroft for the first time, create `$HOME/.config/mycroft/mycroft.conf` with the following contents:
 
 ```
 {
diff --git a/bin/mycroft-config b/bin/mycroft-config
index a1271b328df..435ceb607d8 100755
--- a/bin/mycroft-config
+++ b/bin/mycroft-config
@@ -95,13 +95,13 @@ function validate_config_file() {
     return $result
 }
 
-_conf_file="~/.mycroft/mycroft.conf"
+_conf_file="~/.config/mycroft/mycroft.conf"
 function name_to_path() {
     case ${1} in
         "system")     _conf_file="/etc/mycroft/mycroft.conf" ;;
-        "user")       _conf_file=$(readlink -f ~/.mycroft/mycroft.conf) ;;
+        "user")       _conf_file=$(readlink -f ~/.config/mycroft/mycroft.conf) ;;
         "default")    _conf_file="$DIR/../mycroft/configuration/mycroft.conf" ;;
-        "remote")     _conf_file="/var/tmp/mycroft_web_cache.json" ;;
+        "remote")     _conf_file="~/.cache/mycroft/web_cache.json" ;;
 
         *)
             echo "ERROR: Unknown name '${1}'."
diff --git a/mycroft/api/__init__.py b/mycroft/api/__init__.py
index 43663ee1270..d2843120ef4 100644
--- a/mycroft/api/__init__.py
+++ b/mycroft/api/__init__.py
@@ -20,8 +20,6 @@ import requests
 from requests import HTTPError, RequestException
 
 from mycroft.configuration import Configuration
-from mycroft.configuration.config import DEFAULT_CONFIG, SYSTEM_CONFIG, \
-    USER_CONFIG
 from mycroft.identity import IdentityManager, identity_lock
 from mycroft.version import VersionManager
 from mycroft.util import get_arch, connected, LOG
@@ -49,12 +47,9 @@ class Api:
     def __init__(self, path):
         self.path = path
 
-        # Load the config, skipping the REMOTE_CONFIG since we are
+        # Load the config, skipping the remote config since we are
         # getting the info needed to get to it!
-        config = Configuration.get([DEFAULT_CONFIG,
-                                    SYSTEM_CONFIG,
-                                    USER_CONFIG],
-                                   cache=False)
+        config = Configuration.get(cache=False, remote=False)
         config_server = config.get("server")
         self.url = config_server.get("url")
         self.version = config_server.get("version")
@@ -238,9 +233,7 @@ class DeviceApi(Api):
         platform_build = ""
 
         # load just the local configs to get platform info
-        config = Configuration.get([SYSTEM_CONFIG,
-                                    USER_CONFIG],
-                                   cache=False)
+        config = Configuration.get(cache=False, remote=False)
         if "enclosure" in config:
             platform = config.get("enclosure").get("platform", "unknown")
             platform_build = config.get("enclosure").get("platform_build", "")
@@ -262,9 +255,7 @@ class DeviceApi(Api):
         platform_build = ""
 
         # load just the local configs to get platform info
-        config = Configuration.get([SYSTEM_CONFIG,
-                                    USER_CONFIG],
-                                   cache=False)
+        config = Configuration.get(cache=False, remote=False)
         if "enclosure" in config:
             platform = config.get("enclosure").get("platform", "unknown")
             platform_build = config.get("enclosure").get("platform_build", "")
diff --git a/mycroft/client/enclosure/__main__.py b/mycroft/client/enclosure/__main__.py
index 20cb41aaac2..fdcadf08411 100644
--- a/mycroft/client/enclosure/__main__.py
+++ b/mycroft/client/enclosure/__main__.py
@@ -17,7 +17,7 @@
 This provides any "enclosure" specific functionality, for example GUI or
 control over the Mark-1 Faceplate.
 """
-from mycroft.configuration import LocalConf, SYSTEM_CONFIG
+from mycroft.configuration import Configuration
 from mycroft.util.log import LOG
 from mycroft.util import (create_daemon, wait_for_exit_signal,
                           reset_sigint_handler)
@@ -59,8 +59,8 @@ def main():
     only the GUI bus will be started.
     """
     # Read the system configuration
-    system_config = LocalConf(SYSTEM_CONFIG)
-    platform = system_config.get("enclosure", {}).get("platform")
+    config = Configuration.get(remote=False)
+    platform = config.get("enclosure", {}).get("platform")
 
     enclosure = create_enclosure(platform)
     if enclosure:
diff --git a/mycroft/client/enclosure/mark1/__init__.py b/mycroft/client/enclosure/mark1/__init__.py
index 26a7311c791..c02566d3435 100644
--- a/mycroft/client/enclosure/mark1/__init__.py
+++ b/mycroft/client/enclosure/mark1/__init__.py
@@ -15,8 +15,10 @@
 import subprocess
 import time
 import sys
+import os
 from alsaaudio import Mixer
 from threading import Thread, Timer
+from xdg import BaseDirectory
 
 import serial
 
@@ -29,7 +31,7 @@ from mycroft.client.enclosure.mark1.eyes import EnclosureEyes
 from mycroft.client.enclosure.mark1.mouth import EnclosureMouth
 from mycroft.enclosure.display_manager import \
     init_display_manager_bus_connection
-from mycroft.configuration import Configuration, LocalConf, USER_CONFIG
+from mycroft.configuration import Configuration, LocalConf
 from mycroft.messagebus.message import Message
 from mycroft.util import play_wav, create_signal, connected, check_for_signal
 from mycroft.util.audio_test import record
@@ -163,6 +165,9 @@ class EnclosureReader(Thread):
         if "unit.factory-reset" in data:
             self.bus.emit(Message("speak", {
                 'utterance': mycroft.dialog.get("reset to factory defaults")}))
+            subprocess.call(
+                'rm ~/.config/mycroft/identity/identity2.json',
+                shell=True)
             subprocess.call(
                 'rm ~/.mycroft/identity/identity2.json',
                 shell=True)
@@ -193,7 +198,8 @@ class EnclosureReader(Thread):
 
             LOG.info("Setting opt_in to: " + word)
             new_config = {'opt_in': enable}
-            user_config = LocalConf(USER_CONFIG)
+            user_config = LocalConf(os.path.join(
+                BaseDirectory.save_config_path('mycroft'), 'mycroft.conf'))
             user_config.merge(new_config)
             user_config.store()
 
diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py
index 32011be0095..f5d7d336026 100644
--- a/mycroft/client/speech/hotword_factory.py
+++ b/mycroft/client/speech/hotword_factory.py
@@ -26,10 +26,11 @@ from os.path import dirname, exists, join, abspath, expanduser, isfile, isdir
 from shutil import rmtree
 from threading import Timer, Event, Thread
 from urllib.error import HTTPError
+from xdg import BaseDirectory
 
 from petact import install_package
 
-from mycroft.configuration import Configuration, LocalConf, USER_CONFIG
+from mycroft.configuration import Configuration, LocalConf
 from mycroft.util.log import LOG
 
 RECOGNIZER_DIR = join(abspath(dirname(__file__)), "recognizer")
@@ -137,7 +138,17 @@ class PreciseHotword(HotWordEngine):
         from precise_runner import (
             PreciseRunner, PreciseEngine, ReadWriteStream
         )
-        local_conf = LocalConf(USER_CONFIG)
+
+        old_path = join(expanduser('~'), './mycroft/mycroft.conf')
+        if isfile(old_path):
+            local_conf = old_path
+        else:
+            for dir in BaseDirectory.load_config_paths('mycroft'):
+                local_conf = LocalConf(join(dir, 'mycroft.conf'))
+                # If the current config contains the precise key use it,
+                # otherwise continue to the next file
+                if local_conf.get('precise', None) is not None:
+                    break
         if (local_conf.get('precise', {}).get('dist_url') ==
                 'http://bootstrap.mycroft.ai/artifacts/static/daily/'):
             del local_conf['precise']['dist_url']
@@ -195,7 +206,10 @@ class PreciseHotword(HotWordEngine):
 
     @property
     def folder(self):
-        return join(expanduser('~'), '.mycroft', 'precise')
+        old_path = join(expanduser('~'), '.mycroft', 'precise')
+        if os.path.isdir(old_path):
+            return old_path
+        return join(BaseDirectory.save_data_path('mycroft', 'precise'))
 
     @property
     def install_destination(self):
@@ -305,8 +319,23 @@ class SnowboyHotWord(HotWordEngine):
 class PorcupineHotWord(HotWordEngine):
     def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
         super(PorcupineHotWord, self).__init__(key_phrase, config, lang)
+
+        xdg_data_path = None
+
+        # Use the old path if available
+        old_path = join(expanduser('~'), '.mycroft', 'Porcupine')
+        if os.path.isdir(old_path):
+            xdg_data_path = old_path
+
+        # Otherwise use the new XDG config dirs
+        if xdg_data_path is None:
+            for dir in BaseDirectory.load_data_paths('mycroft', 'Porcupine'):
+                if os.path.isdir(dir):
+                    xdg_data_path = dir
+                    break
+
         porcupine_path = expanduser(self.config.get(
-            "porcupine_path", join('~', '.mycroft', 'Porcupine')))
+            "porcupine_path", xdg_data_path))
         keyword_file_paths = [expanduser(x.strip()) for x in self.config.get(
             "keyword_file_path", "hey_mycroft.ppn").split(',')]
         sensitivities = self.config.get("sensitivities", 0.5)
diff --git a/mycroft/client/text/text_client.py b/mycroft/client/text/text_client.py
index 44d11d61087..734e14ca83f 100644
--- a/mycroft/client/text/text_client.py
+++ b/mycroft/client/text/text_client.py
@@ -15,6 +15,7 @@
 import sys
 import io
 from math import ceil
+from xdg import BaseDirectory
 
 from .gui_server import start_qml_gui
 
@@ -142,8 +143,7 @@ def handleNonAscii(text):
 ##############################################################################
 # Settings
 
-config_file = os.path.join(os.path.expanduser("~"), ".mycroft_cli.conf")
-
+filename = "mycroft_cli.conf"
 
 def load_mycroft_config(bus):
     """ Load the mycroft config and connect it to updates over the messagebus.
@@ -171,6 +171,25 @@ def load_settings():
     global max_log_lines
     global show_meter
 
+    config_file = None
+
+    # Old location
+    path = os.path.join(os.path.expanduser("~"), ".mycroft_cli.conf")
+    if os.path.isfile(path):
+        config_file = path
+
+    # Check XDG_CONFIG_DIR
+    if config_file is None:
+        for dir in BaseDirectory.load_config_paths('mycroft'):
+            file = os.path.join(dir, filename)
+            if os.path.isfile(file):
+                config_file = file
+                break
+
+    # Check /etc/mycroft
+    if config_file is None:
+        config_file = os.path.join("/etc/mycroft", filename)
+
     try:
         with io.open(config_file, 'r') as f:
             config = json.load(f)
@@ -195,7 +214,11 @@ def save_settings():
     config["cy_chat_area"] = cy_chat_area
     config["show_last_key"] = show_last_key
     config["max_log_lines"] = max_log_lines
-    config["show_meter"] = show_meter
+    config["show_meter"] = show_meteri
+
+    config_file = os.path.join(
+        BaseDirectory.save_config_path("mycroft"), filename)
+
     with io.open(config_file, 'w') as f:
         f.write(str(json.dumps(config, ensure_ascii=False)))
 
diff --git a/mycroft/configuration/__init__.py b/mycroft/configuration/__init__.py
index da28826c11d..b920d9c8336 100644
--- a/mycroft/configuration/__init__.py
+++ b/mycroft/configuration/__init__.py
@@ -13,4 +13,3 @@
 # limitations under the License.
 #
 from .config import Configuration, LocalConf, RemoteConf
-from .locations import SYSTEM_CONFIG, USER_CONFIG
diff --git a/mycroft/configuration/config.py b/mycroft/configuration/config.py
index 4322dfdb92f..fee89e9ad91 100644
--- a/mycroft/configuration/config.py
+++ b/mycroft/configuration/config.py
@@ -17,15 +17,13 @@
 import re
 import json
 import inflection
-from os.path import exists, isfile
+from os.path import exists, isfile, join, expanduser, dirname
 from requests import RequestException
+from xdg import BaseDirectory
 
 from mycroft.util.json_helper import load_commented_json, merge_dict
 from mycroft.util.log import LOG
 
-from .locations import (DEFAULT_CONFIG, SYSTEM_CONFIG, USER_CONFIG,
-                        WEB_CONFIG_CACHE)
-
 
 def is_remote_list(values):
     ''' check if this list corresponds to a backend formatted collection of
@@ -135,7 +133,8 @@ class RemoteConf(LocalConf):
     def __init__(self, cache=None):
         super(RemoteConf, self).__init__(None)
 
-        cache = cache or WEB_CONFIG_CACHE
+        cache = cache or join(BaseDirectory.save_cache_path('mycroft'),
+                              'web_cache.json')
         from mycroft.api import is_paired
         if not is_paired():
             self.load_local(cache)
@@ -180,7 +179,7 @@ class Configuration:
     __patch = {}  # Patch config that skills can update to override config
 
     @staticmethod
-    def get(configs=None, cache=True):
+    def get(configs=None, cache=True, remote=True):
         """
             Get configuration, returns cached instance if available otherwise
             builds a new configuration dict.
@@ -188,27 +187,55 @@ class Configuration:
             Args:
                 configs (list): List of configuration dicts
                 cache (boolean): True if the result should be cached
+                remote (boolean): False if the Mycroft Home settings shouldn't
+                                  be loaded
         """
         if Configuration.__config:
             return Configuration.__config
         else:
-            return Configuration.load_config_stack(configs, cache)
+            return Configuration.load_config_stack(configs, cache, remote)
 
     @staticmethod
-    def load_config_stack(configs=None, cache=False):
+    def load_config_stack(configs=None, cache=False, remote=True):
         """
             load a stack of config dicts into a single dict
 
             Args:
                 configs (list): list of dicts to load
                 cache (boolean): True if result should be cached
+                remote (boolean): False if the Mycroft Home settings shouldn't
+                                  be loaded
 
             Returns: merged dict of all configuration files
         """
         if not configs:
-            configs = [LocalConf(DEFAULT_CONFIG), RemoteConf(),
-                       LocalConf(SYSTEM_CONFIG), LocalConf(USER_CONFIG),
-                       Configuration.__patch]
+            # First use patched config
+            configs = [LocalConf(Configuration.__patch)]
+
+            # Then use XDG config
+            # This includes both the user config and
+            # /etc/xdg/mycroft/mycroft.conf
+            for dir in BaseDirectory.load_config_paths('mycroft'):
+                configs.append(LocalConf(join(dir, 'mycroft.conf')))
+
+            # Then check the old user config
+            old_path = join(expanduser('~'), '.mycroft/mycroft.conf')
+            if isfile(old_path):
+                configs.append(LocalConf(old_path))
+
+            # Then use remote config
+            if remote:
+                configs.append(RemoteConf())
+
+            # Then use /etc/mycroft/mycroft.conf
+            configs.append(LocalConf('/etc/mycroft/mycroft.conf'))
+
+            # Then use the config that comes with the package
+            configs.append(LocalConf(join(dirname(__file__), 'mycroft.conf')))
+
+            # Make sure we reverse the array, as merge_dict will put every new
+            # file on top of the previous one
+            configs = reversed(configs)
         else:
             # Handle strings in stack
             for index, item in enumerate(configs):
diff --git a/mycroft/configuration/locations.py b/mycroft/configuration/locations.py
deleted file mode 100644
index cbbaab6ca94..00000000000
--- a/mycroft/configuration/locations.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2018 Mycroft AI Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-import os
-from os.path import join, dirname, expanduser, exists
-
-DEFAULT_CONFIG = join(dirname(__file__), 'mycroft.conf')
-SYSTEM_CONFIG = os.environ.get('MYCROFT_SYSTEM_CONFIG',
-                               '/etc/mycroft/mycroft.conf')
-USER_CONFIG = join(expanduser('~'), '.mycroft/mycroft.conf')
-REMOTE_CONFIG = "mycroft.ai"
-WEB_CONFIG_CACHE = os.environ.get('MYCROFT_WEB_CACHE',
-                                  '/var/tmp/mycroft_web_cache.json')
-
-
-def __ensure_folder_exists(path):
-    """ Make sure the directory for the specified path exists.
-
-        Arguments:
-            path (str): path to config file
-     """
-    directory = dirname(path)
-    if not exists(directory):
-        os.makedirs(directory)
-
-
-__ensure_folder_exists(WEB_CONFIG_CACHE)
-__ensure_folder_exists(USER_CONFIG)
diff --git a/mycroft/configuration/mycroft.conf b/mycroft/configuration/mycroft.conf
index b3e324eb553..798a88567cf 100644
--- a/mycroft/configuration/mycroft.conf
+++ b/mycroft/configuration/mycroft.conf
@@ -5,7 +5,7 @@
   // overridden at the REMOTE level (set by the user via
   // https://home.mycroft.ai), at the SYSTEM level (typically in the file
   // '/etc/mycroft/mycroft.conf'), or at the USER level (typically in the
-  // file '~/.mycroft/mycroft.conf').
+  // file '~/.config/mycroft/mycroft.conf').
   //
   // The load order of settings is:
   //   DEFAULT
@@ -107,7 +107,7 @@
     },
     "upload_skill_manifest": true,
     // Directory to look for user skills
-    "directory": "~/.mycroft/skills",
+    "directory": "~/.local/share/mycroft/skills",
     // Enable auto update by msm
     "auto_update": true,
     // blacklisted skills to not load
@@ -210,7 +210,7 @@
         "threshold": 1e-90,
         "lang": "en-us"
         // Specify custom model via:
-        // "local_model_file": "~/.mycroft/precise/models/something.pb"
+        // "local_model_file": "~/.local/share/mycroft/precise/models/something.pb"
         // Precise options:
         // "sensitivity": 0.5,  // Higher = more sensitive
         // "trigger_level": 3   // Higher = more delay & less sensitive
@@ -303,7 +303,7 @@
   },
 
   "padatious": {
-    "intent_cache": "~/.mycroft/intent_cache",
+    "intent_cache": "~/.local/share/mycroft/intent_cache",
     "train_delay": 4,
     "single_thread": false
   },
diff --git a/mycroft/filesystem/__init__.py b/mycroft/filesystem/__init__.py
index 45ec15a4ac5..414069573f4 100644
--- a/mycroft/filesystem/__init__.py
+++ b/mycroft/filesystem/__init__.py
@@ -14,6 +14,7 @@
 #
 import os
 from os.path import join, expanduser, isdir
+from xdg import BaseDirectory
 
 
 class FileSystemAccess:
@@ -30,7 +31,13 @@ class FileSystemAccess:
     def __init_path(path):
         if not isinstance(path, str) or len(path) == 0:
             raise ValueError("path must be initialized as a non empty string")
-        path = join(expanduser('~'), '.mycroft', path)
+        old_path = join(expanduser('~'), '.mycroft', path)
+        if isdir(old_path):
+            path = old_path
+        else:
+            # Use save_config_path rather than load_first_config to make sure
+            # this directory exists and the skills don't have to deal with it
+            path = join(BaseDirectory.save_config_path('mycroft'), path)
 
         if not isdir(path):
             os.makedirs(path)
diff --git a/mycroft/messagebus/send_func.py b/mycroft/messagebus/send_func.py
index 403db9f45c1..a11a9b0a591 100644
--- a/mycroft/messagebus/send_func.py
+++ b/mycroft/messagebus/send_func.py
@@ -15,8 +15,6 @@
 from websocket import create_connection
 
 from mycroft.configuration import Configuration
-from mycroft.configuration.locations import (DEFAULT_CONFIG, SYSTEM_CONFIG,
-                                             USER_CONFIG)
 from mycroft.messagebus.client import MessageBusClient
 from mycroft.messagebus.message import Message
 
@@ -32,10 +30,7 @@ def send(message_to_send, data_to_send=None):
     data_to_send = data_to_send or {}
 
     # Calculate the standard Mycroft messagebus websocket address
-    config = Configuration.get([DEFAULT_CONFIG,
-                                SYSTEM_CONFIG,
-                                USER_CONFIG],
-                               cache=False)
+    config = Configuration.get(cache=False, remote=False)
     config = config.get("websocket")
     url = MessageBusClient.build_url(
         config.get("host"),
diff --git a/mycroft/skills/event_scheduler.py b/mycroft/skills/event_scheduler.py
index fe41ac1bedc..cb1c9f3c61d 100644
--- a/mycroft/skills/event_scheduler.py
+++ b/mycroft/skills/event_scheduler.py
@@ -20,6 +20,7 @@ import time
 from datetime import datetime, timedelta
 from threading import Thread, Lock
 from os.path import isfile, join, expanduser
+from xdg import BaseDirectory
 
 from mycroft.configuration import Configuration
 from mycroft.messagebus.message import Message
@@ -54,14 +55,19 @@ class EventScheduler(Thread):
     """
     def __init__(self, bus, schedule_file='schedule.json'):
         super().__init__()
-        data_dir = expanduser(Configuration.get()['data_dir'])
 
         self.events = {}
         self.event_lock = Lock()
 
         self.bus = bus
         self.is_running = True
-        self.schedule_file = join(data_dir, schedule_file)
+        old_path = join(expanduser(Configuration.get()['data_dir']),
+                        schedule_file)
+        if isfile(old_path):
+            self.schedule_file = old_path
+        else:
+            self.schedule_file = join(
+                BaseDirectory.load_first_config('mycroft'), schedule_file)
         if self.schedule_file:
             self.load()
 
diff --git a/mycroft/skills/skill_updater.py b/mycroft/skills/skill_updater.py
index 9535ad90319..bf373ba99f8 100644
--- a/mycroft/skills/skill_updater.py
+++ b/mycroft/skills/skill_updater.py
@@ -17,6 +17,7 @@ import os
 import sys
 from datetime import datetime
 from time import time
+from xdg import BaseDirectory
 
 from msm import MsmException
 
@@ -91,9 +92,9 @@ class SkillUpdater:
                     '.mycroft-skills'
                 )
             else:
-                self._installed_skills_file_path = os.path.expanduser(
-                    '~/.mycroft/.mycroft-skills'
-                )
+                self._installed_skills_file_path = join(
+                    BaseDirectory.save_data_path('mycroft',
+                                                 '.mycroft-skills'))
 
         return self._installed_skills_file_path
 
diff --git a/mycroft/util/file_utils.py b/mycroft/util/file_utils.py
index 84555fc3bb3..7c09fd226ee 100644
--- a/mycroft/util/file_utils.py
+++ b/mycroft/util/file_utils.py
@@ -22,6 +22,7 @@ import os
 import psutil
 from stat import S_ISREG, ST_MTIME, ST_MODE, ST_SIZE
 import tempfile
+from xdg import BaseDirectory
 
 import mycroft.configuration
 from .log import LOG
@@ -33,15 +34,15 @@ def resolve_resource_file(res_name):
     Resource names are in the form: 'filename.ext'
     or 'path/filename.ext'
 
-    The system wil look for ~/.mycroft/res_name first, and
-    if not found will look at /opt/mycroft/res_name,
-    then finally it will look for res_name in the 'mycroft/res'
-    folder of the source code package.
+    The system wil look for $XDG_DATA_DIRS/mycroft/res_name first
+    (defaults to ~/.local/share/mycroft/res_name), and if not found will
+    look at /opt/mycroft/res_name, then finally it will look for res_name
+    in the 'mycroft/res' folder of the source code package.
 
     Example:
     With mycroft running as the user 'bob', if you called
         resolve_resource_file('snd/beep.wav')
-    it would return either '/home/bob/.mycroft/snd/beep.wav' or
+    it would return either '/home/bob/.local/share/mycroft/snd/beep.wav' or
     '/opt/mycroft/snd/beep.wav' or '.../mycroft/res/snd/beep.wav',
     where the '...' is replaced by the path where the package has
     been installed.
@@ -57,8 +58,14 @@ def resolve_resource_file(res_name):
     if os.path.isfile(res_name):
         return res_name
 
-    # Now look for ~/.mycroft/res_name (in user folder)
-    filename = os.path.expanduser("~/.mycroft/" + res_name)
+    # Now look for XDG_DATA_DIRS
+    for dir in BaseDirectory.load_data_paths('mycroft'):
+        filename = os.path.join(dir, res_name)
+        if os.path.isfile(filename):
+            return filename
+
+    # Now look in the old user location
+    filename = os.path.join(os.path.expanduser('~'), '.mycroft', res_name)
     if os.path.isfile(filename):
         return filename
 
diff --git a/mycroft/util/log.py b/mycroft/util/log.py
index 0ea391f8f79..788f6df1c37 100644
--- a/mycroft/util/log.py
+++ b/mycroft/util/log.py
@@ -21,7 +21,7 @@ This module provides the LOG pseudo function quickly creating a logger instance
 for use.
 
 The default log level of the logger created here can ONLY be set in
-/etc/mycroft/mycroft.conf or ~/.mycroft/mycroft.conf
+/etc/mycroft/mycroft.conf or ~/.config/mycroft/mycroft.conf
 
 The default log level can also be programatically be changed by setting the
 LOG.level parameter.
@@ -31,10 +31,10 @@ import inspect
 import logging
 import sys
 
-from os.path import isfile
+from os.path import isfile, join
+from xdg import BaseDirectory
 
 from mycroft.util.json_helper import load_commented_json, merge_dict
-from mycroft.configuration.locations import SYSTEM_CONFIG, USER_CONFIG
 
 
 def getLogger(name="MYCROFT"):
@@ -84,7 +84,10 @@ class LOG:
         # Check configs manually, the Mycroft configuration system can't be
         # used since it uses the LOG system and would cause horrible cyclic
         # dependencies.
-        confs = [SYSTEM_CONFIG, USER_CONFIG]
+        confs = []
+        for dir in BaseDirectory.load_config_paths('mycroft'):
+            confs.append(join(dir, 'mycroft.conf'))
+        confs.append('/etc/mycroft/mycroft.conf')
         config = {}
         for conf in confs:
             try:
diff --git a/test/unittests/skills/test_skill_updater.py b/test/unittests/skills/test_skill_updater.py
index 38d4083d7f2..a1fda04fb3a 100644
--- a/test/unittests/skills/test_skill_updater.py
+++ b/test/unittests/skills/test_skill_updater.py
@@ -15,6 +15,7 @@
 """Unit tests for the SkillUpdater class."""
 from os import path
 from time import sleep
+from xdg import BaseDirectory
 from unittest.mock import Mock, patch, PropertyMock
 
 from mycroft.skills.skill_updater import SkillUpdater
@@ -143,7 +144,8 @@ class TestSkillUpdater(MycroftUnitTestBase):
             os_patch.return_value = False
             updater = SkillUpdater(self.message_bus_mock)
             self.assertEqual(
-                path.expanduser('~/.mycroft/.mycroft-skills'),
+                join(BaseDirectory.save_data_path('mycroft'),
+                     'mycroft-skills'),
                 updater.installed_skills_file_path
             )
 
diff --git a/test/unittests/util/commented.json b/test/unittests/util/commented.json
index 87c7d3e2c2d..00a581f6df4 100644
--- a/test/unittests/util/commented.json
+++ b/test/unittests/util/commented.json
@@ -54,7 +54,7 @@
     }
   },
   "skills": {
-    "directory": "~/.mycroft/skills"
+    "directory": "~/.local/share/mycroft/skills"
   },
   "server": {
     "url": "https://api.mycroft.ai",
diff --git a/test/unittests/util/plain.json b/test/unittests/util/plain.json
index f8c474139ce..eec84631d88 100644
--- a/test/unittests/util/plain.json
+++ b/test/unittests/util/plain.json
@@ -36,7 +36,7 @@
     }
   },
   "skills": {
-    "directory": "~/.mycroft/skills"
+    "directory": "~/.local/share/mycroft/skills"
   },
   "server": {
     "url": "https://api.mycroft.ai",
diff --git a/test/unittests/util/test_file_utils.py b/test/unittests/util/test_file_utils.py
index dcc4d72676c..e409f712950 100644
--- a/test/unittests/util/test_file_utils.py
+++ b/test/unittests/util/test_file_utils.py
@@ -33,7 +33,8 @@ class TestResolveResource(TestCase):
 
         mock_isfile.side_effect = files_in_dotmycroft_exists
         self.assertEqual(resolve_resource_file('1984.txt'),
-                         expanduser('~/.mycroft/1984.txt'))
+                         join(BaseDirectory.save_data_path('mycroft'),
+                              '1984.txt'))
 
     @mock.patch('os.path.isfile')
     def test_data_dir(self, mock_isfile, mock_conf):
diff --git a/test/util.py b/test/util.py
index f80c0f9bd40..f657bdb8304 100644
--- a/test/util.py
+++ b/test/util.py
@@ -1,7 +1,7 @@
-from mycroft.configuration.config import LocalConf, DEFAULT_CONFIG
+from mycroft.configuration.config import LocalConf
 from copy import deepcopy
 
-__config = LocalConf(DEFAULT_CONFIG)
+__config = LocalConf(join(dirname(__file__), 'mycroft.conf'))
 
 
 # Base config to use when mocking