aboutsummaryrefslogtreecommitdiffhomepage
path: root/env_universal_common.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-11-09 17:56:38 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-11-09 17:56:38 -0800
commit220a15b8f61b7333ebaf7986a00f0d4dcf684eb2 (patch)
tree8910beae91cd540a75bad6534fcad5a61171cfef /env_universal_common.cpp
parent330e996c30f2f3f6e812e79f5b28f16bb1b7d04e (diff)
Put the universal variables notifier named pipe in XDG_RUNTIME_DIR
This is where named pipes belong.
Diffstat (limited to 'env_universal_common.cpp')
-rw-r--r--env_universal_common.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/env_universal_common.cpp b/env_universal_common.cpp
index 6cfd0055..e57fe9b8 100644
--- a/env_universal_common.cpp
+++ b/env_universal_common.cpp
@@ -67,13 +67,12 @@
static wcstring fishd_get_config();
static std::string get_variables_file_path(const std::string &dir, const std::string &identifier);
-static wcstring default_vars_path_uncached()
+static wcstring vars_filename_in_directory(const wcstring &wdir)
{
- wcstring wdir = fishd_get_config();
- const std::string dir = wcs2string(wdir);
- if (dir.empty())
+ if (wdir.empty())
return L"";
+ const std::string dir = wcs2string(wdir);
const std::string machine_id = get_machine_identifier();
const std::string machine_id_path = get_variables_file_path(dir, machine_id);
return str2wcstring(machine_id_path);
@@ -81,10 +80,24 @@ static wcstring default_vars_path_uncached()
static const wcstring &default_vars_path()
{
- static wcstring cached_result = default_vars_path_uncached();
+ static wcstring cached_result = vars_filename_in_directory(fishd_get_config());
return cached_result;
}
+/* Like default_vars_path, but returns a file in XDG_RUNTIME_DIR, if present. This is called infrequently and so does not need to be cached. */
+static wcstring default_named_pipe_path()
+{
+ env_var_t xdg_runtime_wdir = env_get_string(L"XDG_RUNTIME_DIR", ENV_GLOBAL | ENV_EXPORT);
+ if (! xdg_runtime_wdir.missing_or_empty())
+ {
+ return vars_filename_in_directory(xdg_runtime_wdir);
+ }
+ else
+ {
+ return default_vars_path();
+ }
+}
+
/**
Test if the message msg contains the command cmd
*/
@@ -1277,7 +1290,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t
void make_pipe(const wchar_t *test_path)
{
- wcstring vars_path = test_path ? wcstring(test_path) : default_vars_path();
+ wcstring vars_path = test_path ? wcstring(test_path) : default_named_pipe_path();
vars_path.append(L".notifier");
const std::string narrow_path = wcs2string(vars_path);