aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-05-06 22:07:14 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-05-06 22:10:05 +0200
commitba8657d8fef11d20d1b0c24cfc7f439aa2200797 (patch)
tree7eacf23711493f2ddacf993e3bdfdc977060d090
parent9e437bd921c279f14eaaf58ba87b25c132aa0184 (diff)
downloaddesktop-tools-ba8657d8fef11d20d1b0c24cfc7f439aa2200797.tar.gz
desktop-tools-ba8657d8fef11d20d1b0c24cfc7f439aa2200797.tar.xz
desktop-tools-ba8657d8fef11d20d1b0c24cfc7f439aa2200797.zip
wmstatus: simplify spawning
MPD and NUT sockets are FD_CLOEXEC already, do the same with Xlib.
-rw-r--r--wmstatus.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/wmstatus.c b/wmstatus.c
index 00dafdf..8568ce3 100644
--- a/wmstatus.c
+++ b/wmstatus.c
@@ -1,7 +1,7 @@
/*
* wmstatus.c: simple PulseAudio-enabled status setter for dwm and i3
*
- * Copyright (c) 2015 - 2016, Přemysl Janouch <p.janouch@gmail.com>
+ * Copyright (c) 2015 - 2017, Přemysl Janouch <p.janouch@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1210,6 +1210,7 @@ app_context_init (struct app_context *self)
poller_init (&self->poller);
self->api = poller_pa_new (&self->poller);
+ set_cloexec (ConnectionNumber (self->dpy));
poller_fd_init (&self->x_event, &self->poller,
ConnectionNumber (self->dpy));
@@ -2072,17 +2073,11 @@ on_make_context (void *user_data)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static void
-spawn (struct app_context *ctx, char *argv[])
+spawn (char *argv[])
{
posix_spawn_file_actions_t actions;
posix_spawn_file_actions_init (&actions);
- posix_spawn_file_actions_addclose (&actions, ConnectionNumber (ctx->dpy));
- if (ctx->mpd_client.socket != -1)
- posix_spawn_file_actions_addclose (&actions, ctx->mpd_client.socket);
- if (ctx->nut_client.socket != -1)
- posix_spawn_file_actions_addclose (&actions, ctx->nut_client.socket);
-
// That would mess up our JSON
posix_spawn_file_actions_addopen
(&actions, STDOUT_FILENO, "/dev/null", O_WRONLY, 0);
@@ -2190,29 +2185,32 @@ on_volume_set (struct app_context *ctx, int arg)
static void
on_lock (struct app_context *ctx, int arg)
{
+ (void) ctx;
(void) arg;
// One of these will work
char *argv_gdm[] = { "gdm-switch-user", NULL };
- spawn (ctx, argv_gdm);
+ spawn (argv_gdm);
char *argv_ldm[] = { "dm-tool", "lock", NULL };
- spawn (ctx, argv_ldm);
+ spawn (argv_ldm);
}
static void
on_input_switch (struct app_context *ctx, int arg)
{
+ (void) ctx;
char *values[] = { "vga", "dvi", "dp", "hdmi" };
char *argv[] = { "input-switch", values[arg], NULL };
- spawn (ctx, argv);
+ spawn (argv);
}
static void
on_brightness (struct app_context *ctx, int arg)
{
+ (void) ctx;
char *value = xstrdup_printf ("%d", arg);
char *argv[] = { "brightness", value, NULL };
- spawn (ctx, argv);
+ spawn (argv);
free (value);
}