Incorporate the display name into the default socket path

Fixes #105
This commit is contained in:
Bastien Dejean 2013-12-23 11:41:10 +01:00
parent 5e037978dd
commit a7fe634bf0
5 changed files with 16 additions and 16 deletions

8
bspc.c
View file

@ -42,10 +42,12 @@ int main(int argc, char *argv[])
if (argc < 2)
err("No arguments given.\n");
char *sp = getenv(SOCKET_ENV_VAR);
sock_address.sun_family = AF_UNIX;
snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", (sp == NULL ? DEFAULT_SOCKET_PATH : sp));
char *sp = getenv(SOCKET_ENV_VAR);
if (sp != NULL)
snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", sp);
else
snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), SOCKET_PATH_TPL, getenv("DISPLAY"));
argc--, argv++;
int msg_len = 0;

View file

@ -97,11 +97,13 @@ int main(int argc, char *argv[])
dpy_fd = xcb_get_file_descriptor(dpy);
char *sp = getenv(SOCKET_ENV_VAR);
snprintf(socket_path, sizeof(socket_path), "%s", (sp == NULL ? DEFAULT_SOCKET_PATH : sp));
if (sp != NULL)
snprintf(socket_path, sizeof(socket_path), "%s", sp);
else
snprintf(socket_path, sizeof(socket_path), SOCKET_PATH_TPL, getenv("DISPLAY"));
sock_address.sun_family = AF_UNIX;
snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", socket_path);
unlink(socket_path);
sock_fd = socket(AF_UNIX, SOCK_STREAM, 0);
@ -180,6 +182,7 @@ int main(int argc, char *argv[])
cleanup();
close(sock_fd);
unlink(socket_path);
xcb_ewmh_connection_wipe(ewmh);
xcb_destroy_window(dpy, motion_recorder);
free(ewmh);

View file

@ -25,7 +25,7 @@
#ifndef BSPWM_COMMON_H
#define BSPWM_COMMON_H
#define DEFAULT_SOCKET_PATH "/tmp/bspwm-socket"
#define SOCKET_PATH_TPL "/tmp/bspwm%s-socket"
#define SOCKET_ENV_VAR "BSPWM_SOCKET"
#define MESSAGE_FAILURE '\x18'

View file

@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 12/16/2013
.\" Date: 12/23/2013
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.8.7
.\" Language: English
.\"
.TH "BSPWM" "1" "12/16/2013" "Bspwm 0\&.8\&.7" "Bspwm Manual"
.TH "BSPWM" "1" "12/23/2013" "Bspwm 0\&.8\&.7" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -1169,11 +1169,6 @@ Layout of the focused desktop of the focused monitor\&.
.PP
\fIBSPWM_SOCKET\fR
.RS 4
The path of the socket used for the communication between
\fBbspc\fR
and
\fBbspwm\fR\&. If it isn\(cqt defined, then the following path is used:
\fI/tmp/bspwm\-socket\fR\&.
.RE
.SH "PANELS"
.sp

View file

@ -724,7 +724,7 @@ Environment Variables
---------------------
'BSPWM_SOCKET'::
The path of the socket used for the communication between *bspc* and *bspwm*. If it isn't defined, then the following path is used: '/tmp/bspwm-socket'.
The path of the socket used for the communication between *bspc* and *bspwm*. If it isn't defined, then the following path is used: '/tmp/bspwm${DISPLAY}-socket'.
Panels
------