summarylogtreecommitdiffstats
path: root/0.8-api-changes.patch
blob: 3a6654ffd75c64121d08faf5885e81c40872a2f3 (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
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
X-Git-Url: http://git.freebsoft.org/?p=speechd.git;a=blobdiff_plain;f=src%2Fapi%2Fpython%2Fspeechd%2Fclient.py;h=8d3436334e3d3ca9e5884ae595ec9ba1f21b2375;hp=3d28f4f44e21babce36b17063ddb4f3bb4256a5d;hb=f818b657ab8da32ef2f212eebb453bf054f7afdb;hpb=728f531c50144ed7f46179363c1215a7d0453e16

diff --git a/src/python/speechd/client.py b/src/python/speechd/client.py
index 3d28f4f..8d34363 100644
--- a/src/python/speechd/client.py
+++ b/src/python/speechd/client.py
@@ -494,7 +494,7 @@ class SSIPClient(object):
     """Default host for server connections."""
     DEFAULT_PORT = 6560
     """Default port number for server connections."""
-    DEFAULT_SOCKET_PATH = "~/.speech-dispatcher/speechd.sock"
+    DEFAULT_SOCKET_PATH = "speech-dispatcher/speechd.sock"
     """Default name of the communication unix socket"""
     
     def __init__(self, name, component='default', user='unknown', address=None,
@@ -510,7 +510,7 @@ class SSIPClient(object):
           user -- user identification string (user name).  When multi-user
             acces is expected, this can be used to identify their connections.
           address -- server address as specified in Speech Dispatcher
-            documentation (e.g. "unix:/home/joe/.speech-dispatcher/speechd.sock"
+            documentation (e.g. "unix:/run/user/joe/speech-dispatcher/speechd.sock"
             or "inet:192.168.0.85:6561")
           autospawn -- a flag to specify whether the library should
             try to start the server if it determines its not already
@@ -520,9 +520,9 @@ class SSIPClient(object):
           method -- communication method to use, one of the constants defined in class
             CommunicationMethod
           socket_path -- for CommunicationMethod.UNIX_SOCKET, socket
-            path in filesystem. By default, this is ~/.speech-dispatcher/speechd.sock
-            where `~' is the users home directory as determined from the system
-            defaults and from the $HOMEDIR environment variable.
+            path in filesystem. By default, this is $XDG_RUNTIME_DIR/speech-dispatcher/speechd.sock
+            where $XDG_RUNTIME_DIR is determined using the XDG Base Directory
+            Specification.
           host -- for CommunicationMethod.INET_SOCKET, server hostname
             or IP address as a string.  If None, the default value is
             taken from SPEECHD_HOST environment variable (if it
@@ -536,9 +536,12 @@ class SSIPClient(object):
         Dispatcher documentation.
         """
 
+        _home = os.path.expanduser("~")
+        _runtime_dir = os.environ.get('XDG_RUNTIME_DIR', os.environ.get('XDG_CACHE_HOME', os.path.join(_home, '.cache')))
+        _sock_path = os.path.join(_runtime_dir, self.DEFAULT_SOCKET_PATH)
         # Resolve connection parameters:
         connection_args = {'communication_method': CommunicationMethod.UNIX_SOCKET,
-                           'socket_path': os.path.expanduser(self.DEFAULT_SOCKET_PATH),
+                           'socket_path': _sock_path,
                            'host': self.DEFAULT_HOST,
                            'port': self.DEFAULT_PORT,
                            }
X-Git-Url: http://git.freebsoft.org/?p=speechd.git;a=blobdiff_plain;f=src%2Fapi%2Fpython%2Fspeechd_config%2Fconfig.py;h=47a37105b94318f59bc7c4b1f7f913deb362d245;hp=7bd8a89100e47adf29bca253be39f2e0303c155b;hb=2223ab2455ea17d2e27cb2896496291f158a156b;hpb=ff994b57a340a8b6229f5576c1a202e339169105

diff --git a/src/python/speechd_config/config.py b/src/python/speechd_config/config.py
index 7bd8a89..47a3710 100644
--- a/src/python/speechd_config/config.py
+++ b/src/python/speechd_config/config.py
@@ -26,6 +26,7 @@ import time
 import datetime
 
 from optparse import OptionParser
+from xdg import BaseDirectory
 
 # Configuration and sound data paths
 from . import paths
@@ -272,17 +273,9 @@ class Tests:
     def __init__(self):
         self.festival_socket = None
 
-    def user_speechd_dir(self):
-        """Return user Speech Dispatcher configuration and logging directory"""
-        return os.path.expanduser(os.path.join('~', '.speech-dispatcher'))
-
-    def user_speechd_dir_exists(self):
-        """Determine whether user speechd directory exists"""
-        return os.path.exists(self.user_speechd_dir())
-
     def user_conf_dir(self):
         """Return user configuration directory"""
-        return os.path.join(self.user_speechd_dir(), "conf")
+        return os.path.join(BaseDirectory.xdg_config_home, "speech-dispatcher")
 
     def system_conf_dir(self):
         """Determine system configuration directory"""
@@ -684,32 +677,25 @@ class Configure:
         """Create user configuration in the standard location"""
 
         # Ask before touching things that we do not have to!
-        if test.user_speechd_dir_exists():
-            if test.user_conf_dir_exists():
-                if test.user_configuration_seems_complete():
-                    reply = question(
-                        """User configuration already exists.
-Do you want to rewrite it with a new one?""", False)
-                    if reply == False:
-                        report("Keeping configuration intact and continuing with settings.")
-                        return
-                    else:
-                        self.remove_user_configuration()
+        if test.user_conf_dir_exists():
+            if test.user_configuration_seems_complete():
+                reply = question(
+                    "User configuration already exists."
+                    "Do you want to rewrite it with a new one?", False)
+                if reply == False:
+                    report("Keeping configuration intact and continuing with settings.")
+                    return
                 else:
-                    reply = question(
-                        """User configuration already exists, but it seems to be incomplete.
-Do you want to keep it?""", False)
-                    if reply == False:
-                        self.remove_user_configuration()
-                    else:
-                        report("Keeping configuration intact and aborting.")
-                        return
-
-            # TODO: Check for permissions on logfiles and pid
-        else:
-            report("Creating " + test.user_speechd_dir())
-            os.mkdir(test.user_speechd_dir())
-
+                    self.remove_user_configuration()
+            else:
+                reply = question(
+                    "User configuration already exists, but it seems to be incomplete."
+                    "Do you want to keep it?", False)
+                if reply == False:
+                    self.remove_user_configuration()
+                else:
+                    report("Keeping configuration intact and aborting.")
+                    return
         # Copy the original intact configuration files
         # creating a conf/ subdirectory
         shutil.copytree(paths.SPD_CONF_ORIG_PATH, test.user_conf_dir())