summaryrefslogtreecommitdiff
path: root/src/remote.cc
diff options
context:
space:
mode:
authorJason Felice <jason.m.felice@gmail.com>2019-08-20 16:13:21 -0400
committerJason Felice <jason.m.felice@gmail.com>2019-08-20 16:13:21 -0400
commit8d76603df4de45f8efc85032c38c1fd96daa560c (patch)
tree788328e93bb2ca19e7a35fdbaebcf6454a767180 /src/remote.cc
parent09c514901d84fa9f9be6fa61af183c606e3a5926 (diff)
Fix kak -l when $XDG_RUNTIME_DIR is set
Diffstat (limited to 'src/remote.cc')
-rw-r--r--src/remote.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/remote.cc b/src/remote.cc
index 7f6cb817..8d98533b 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -537,6 +537,15 @@ String get_user_name()
return getenv("USER");
}
+String session_directory()
+{
+ StringView xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
+ if (xdg_runtime_dir.empty())
+ return format("{}/kakoune/{}", tmpdir(), get_user_name());
+ else
+ return format("{}/kakoune", xdg_runtime_dir);
+}
+
void make_session_directory()
{
StringView xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
@@ -544,21 +553,15 @@ void make_session_directory()
{
// set sticky bit on the shared kakoune directory
make_directory(format("{}/kakoune", tmpdir()), 01777);
- make_directory(format("{}/kakoune/{}", tmpdir(), get_user_name()), 0711);
}
- else
- make_directory(format("{}/kakoune", xdg_runtime_dir), 0711);
+ make_directory(session_directory(), 0711);
}
String session_path(StringView session)
{
if (contains(session, '/'))
throw runtime_error{"session names cannot have slashes"};
- StringView xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
- if (xdg_runtime_dir.empty())
- return format("{}/kakoune/{}/{}", tmpdir(), get_user_name(), session);
- else
- return format("{}/kakoune/{}", xdg_runtime_dir, session);
+ return format("{}/{}", session_directory(), session);
}
static sockaddr_un session_addr(StringView session)