XDG standard conform socket location (#158).
authorDaniel Carl <danielcarl@gmx.de>
Thu, 15 Jan 2015 21:19:00 +0000 (22:19 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 15 Jan 2015 21:26:45 +0000 (22:26 +0100)
doc/vimb.1
src/io.c

index 778061a..c0d09fa 100644 (file)
@@ -66,7 +66,7 @@ Run vimb in kiosk mode with nearly no keybindings, not inputbox and no context
 menu.
 .TP
 .B \-s, \-\-socket
-If given vimb will create a control socket.
+If given vimb will create a control socket in the user runtime directory.
 .TP
 .B "\-v, \-\-version"
 Print build and version information.
@@ -1474,6 +1474,9 @@ File for userdefined css styles. These file is used if the config variable
 .TP
 .I $XDG_CACHE_HOME/vimb/
 Default directory for cache data.
+.TP
+.I $XDG_RUNTIME_DIR/vimb/socket/
+Directory where the control sockets are placed.
 .SH ENVIRONMENT
 .TP
 .B http_proxy
index 0cd94ee..1f022d3 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -22,6 +22,7 @@
 #include "io.h"
 #include "main.h"
 #include "map.h"
+#include "util.h"
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -37,14 +38,15 @@ static gboolean socket_watch(GIOChannel *chan);
 
 gboolean io_init_socket(const char *name)
 {
-    char *fname, *path;
+    char *dir, *path;
     int sock;
     struct sockaddr_un local;
 
-    /* create socket in directory as vimb-socket-$PID */
-    fname = g_strdup_printf(PROJECT "-socket-%s", name);
-    path  = g_build_filename(g_get_user_config_dir(), PROJECT, fname, NULL);
-    g_free(fname);
+    /* create socket in runtime directory */
+    dir = g_build_filename(g_get_user_runtime_dir(), PROJECT, "socket", NULL);
+    util_create_dir_if_not_exists(dir);
+    path = g_build_filename(dir, name, NULL);
+    g_free(dir);
 
     /* if the file already exists - remove this first */
     if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {