socket, awesome-client: fix computing if DISPLAY unset
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
99004c3799
commit
fa57be9588
|
@ -116,7 +116,8 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if(isatty(STDIN_FILENO))
|
if(isatty(STDIN_FILENO))
|
||||||
{
|
{
|
||||||
asprintf(&prompt, "awesome@%s%% ", getenv("DISPLAY"));
|
char *display = getenv("DISPLAY");
|
||||||
|
asprintf(&prompt, "awesome@%s%% ", display ? display : "unknown");
|
||||||
while((msg = readline(prompt)))
|
while((msg = readline(prompt)))
|
||||||
if((msg_len = a_strlen(msg)))
|
if((msg_len = a_strlen(msg)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,8 +41,8 @@ struct sockaddr_un *
|
||||||
socket_getaddr(const char *display)
|
socket_getaddr(const char *display)
|
||||||
{
|
{
|
||||||
char *homedir, *host = NULL;
|
char *homedir, *host = NULL;
|
||||||
int screenp, displayp;
|
int screenp = 0, displayp = 0;
|
||||||
ssize_t path_len;
|
ssize_t path_len, len;
|
||||||
struct sockaddr_un *addr;
|
struct sockaddr_un *addr;
|
||||||
|
|
||||||
addr = p_new(struct sockaddr_un, 1);
|
addr = p_new(struct sockaddr_un, 1);
|
||||||
|
@ -50,10 +50,12 @@ socket_getaddr(const char *display)
|
||||||
|
|
||||||
xcb_parse_display(NULL, &host, &displayp, &screenp);
|
xcb_parse_display(NULL, &host, &displayp, &screenp);
|
||||||
|
|
||||||
|
len = a_strlen(host);
|
||||||
|
|
||||||
/* + 2 for / and . and \0 */
|
/* + 2 for / and . and \0 */
|
||||||
path_len = snprintf(addr->sun_path, sizeof(addr->sun_path),
|
path_len = snprintf(addr->sun_path, sizeof(addr->sun_path),
|
||||||
"%s/" CONTROL_UNIX_SOCKET_PATH "%s%s%d",
|
"%s/" CONTROL_UNIX_SOCKET_PATH "%s%s%d",
|
||||||
homedir, host, a_strlen(host) ? "." : "",
|
homedir, len ? host : "", len ? "." : "",
|
||||||
displayp);
|
displayp);
|
||||||
|
|
||||||
p_delete(&host);
|
p_delete(&host);
|
||||||
|
|
Loading…
Reference in New Issue