* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
#include <stdlib.h>
#ifdef __OpenBSD__
#include <sys/types.h>
#include "helpers.h"
#include "common.h"
-extern char *strdup(const char*);
-
int main(int argc, char *argv[])
{
int fd;
err("No arguments given.\n");
sock_address.sun_family = AF_UNIX;
- char *sp, *dp, *tdp;
- int con, it;
- unsigned int dplen;
+ char *sp;
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
err("Failed to create the socket.\n");
sp = getenv(SOCKET_ENV_VAR);
if (sp != NULL) {
snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", sp);
- con = connect(fd, (struct sockaddr *) &sock_address, sizeof(sock_address));
} else {
- con = -1;
- }
-
- dp = getenv("DISPLAY");
- if (con == -1 && dp != NULL) {
- snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), SOCKET_PATH_TPL, dp);
- con = connect(fd, (struct sockaddr *) &sock_address, sizeof(sock_address));
- }
-
- if (con == -1 && dp != NULL) {
- tdp = strdup(dp);
- dplen = strlen(dp);
- for (it = dplen - 1; (it > 1) && (tdp[it] != ':'); it--) {
- if (tdp[it] == '.') {
- tdp[it] = '\0';
- break;
- }
- }
- if (strlen(tdp) != dplen) {
- snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), SOCKET_PATH_TPL, tdp);
- con = connect(fd, (struct sockaddr *) &sock_address, sizeof(sock_address));
- }
- free(tdp);
+ char *host = NULL;
+ int dn = 0, sn = 0;
+ if (xcb_parse_display(NULL, &host, &dn, &sn) != 0)
+ snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), SOCKET_PATH_TPL, host, dn, sn);
+ free(host);
}
- if (con == -1)
+ if (connect(fd, (struct sockaddr *) &sock_address, sizeof(sock_address)) == -1)
err("Failed to connect to the socket.\n");
argc--, argv++;
dpy_fd = xcb_get_file_descriptor(dpy);
char *sp = getenv(SOCKET_ENV_VAR);
- if (sp != NULL)
+ if (sp != NULL) {
snprintf(socket_path, sizeof(socket_path), "%s", sp);
- else
- snprintf(socket_path, sizeof(socket_path), SOCKET_PATH_TPL, getenv("DISPLAY"));
+ } else {
+ char *host = NULL;
+ int dn = 0, sn = 0;
+ if (xcb_parse_display(NULL, &host, &dn, &sn) != 0)
+ snprintf(socket_path, sizeof(socket_path), SOCKET_PATH_TPL, host, dn, sn);
+ free(host);
+ }
sock_address.sun_family = AF_UNIX;
snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s", socket_path);
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 11/19/2014
+.\" Date: 11/23/2014
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.8.9
.\" Language: English
.\"
-.TH "BSPWM" "1" "11/19/2014" "Bspwm 0\&.8\&.9" "Bspwm Manual"
+.TH "BSPWM" "1" "11/23/2014" "Bspwm 0\&.8\&.9" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
\fBbspc\fR
and
\fBbspwm\fR\&. If it isn\(cqt defined, then the following path is used:
-\fI/tmp/bspwm<display_name>\-socket\fR\&.
+\fI/tmp/bspwm<host_name>_<display_number>_<screen_number>\-socket\fR\&.
.RE
.SH "PANELS"
.sp