From: Daniel Carl Date: Thu, 15 Jan 2015 21:19:00 +0000 (+0100) Subject: XDG standard conform socket location (#158). X-Git-Url: https://git.owens.tech/git.owens.tech/git.owens.tech/git?a=commitdiff_plain;h=701f85e6b51f2c9a950dc3e243bacaf6d08aba50;p=vimb.git XDG standard conform socket location (#158). --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 778061a..c0d09fa 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -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 diff --git a/src/io.c b/src/io.c index 0cd94ee..1f022d3 100644 --- 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 #include #include @@ -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)) {