aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2022-10-09 18:25:23 +0200
committertslil clingman <tslil@posteo.de>2022-10-09 18:56:58 +0200
commit32ccd7d35d8ec246b9081028a928d0934b28ee1d (patch)
treec0cfccca9a60cd13e52df279c41cd5a467ae8c82 /monsterwm.c
parentc565c09250f3b1cec255bc1f36a0b373a92467cd (diff)
multimedia keys and fix now playing for mpd, supress stdout on running commands, tweak status
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/monsterwm.c b/monsterwm.c
index fdb68eb..85c0b75 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -1,5 +1,6 @@
/* see license for copyright and license */
#define _XOPEN_SOURCE
+#define _POSIX_C_SOURCE 200112L
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
@@ -428,22 +429,15 @@ void write_status(void) {
printf("%%{r}");
now = time(NULL);
- putenv("TZ=PST8PDT");
- ptm = localtime(&now);
- strftime(buff, sizeof(buff), "%Z %H:%M", ptm);
- printf("%s | ", buff);
-
- putenv("TZ=America/Chicago");
- ptm = localtime(&now);
- strftime(buff, sizeof(buff), "%Z %H:%M", ptm);
- printf("%s | ", buff);
-
- putenv("TZ=UTC");
- ptm = localtime(&now);
- strftime(buff, sizeof(buff), "%Z %H:%M", ptm);
- printf("%s | ", buff);
+ char* const tzs[] = {"TZ=PST8PDT", "TZ=America/Chicago", "TZ=America/New_York", "TZ=UTC", "TZ=Europe/London"};
+ for (unsigned int i=0; i < LENGTH(tzs); i++) {
+ putenv(tzs[i]);
+ ptm = localtime(&now);
+ strftime(buff, sizeof(buff), "%Z %H:%M", ptm);
+ printf("%s | ", buff);
+ }
- putenv("TZ=Europe/Amsterdam");
+ unsetenv("TZ");
ptm = localtime(&now);
strftime(buff, sizeof(buff), "%Z %H:%M:%S %D", ptm);
printf("%s", buff);
@@ -1133,8 +1127,10 @@ void sigchld(__attribute__((unused)) int sig) {
void spawn(const Arg *arg) {
if (fork()) return;
if (dis) close(ConnectionNumber(dis));
+ freopen("/dev/null", "w", stdout); // don't nuke status
setsid();
execvp((char*)arg->com[0], (char**)arg->com);
+ freopen("/dev/tty", "w", stdout);
err(EXIT_SUCCESS, "execvp %s", (char *)arg->com[0]);
}