Adding dwmblocks patch
This commit is contained in:
31
patch/dwmblocks.c
Normal file
31
patch/dwmblocks.c
Normal file
@@ -0,0 +1,31 @@
|
||||
static int dwmblockssig;
|
||||
pid_t dwmblockspid = 0;
|
||||
|
||||
int
|
||||
getdwmblockspid()
|
||||
{
|
||||
char buf[16];
|
||||
FILE *fp = popen("pidof -s dwmblocks", "r");
|
||||
if (fgets(buf, sizeof(buf), fp));
|
||||
pid_t pid = strtoul(buf, NULL, 10);
|
||||
pclose(fp);
|
||||
dwmblockspid = pid;
|
||||
return pid != 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
void
|
||||
sigdwmblocks(const Arg *arg)
|
||||
{
|
||||
union sigval sv;
|
||||
sv.sival_int = (dwmblockssig << 8) | arg->i;
|
||||
if (!dwmblockspid)
|
||||
if (getdwmblockspid() == -1)
|
||||
return;
|
||||
|
||||
if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) {
|
||||
if (errno == ESRCH) {
|
||||
if (!getdwmblockspid())
|
||||
sigqueue(dwmblockspid, SIGUSR1, sv);
|
||||
}
|
||||
}
|
||||
}
|
2
patch/dwmblocks.h
Normal file
2
patch/dwmblocks.h
Normal file
@@ -0,0 +1,2 @@
|
||||
static int getdwmblockspid();
|
||||
static void sigdwmblocks(const Arg *arg);
|
@@ -29,6 +29,9 @@
|
||||
#if DRAGCFACT_PATCH && CFACTS_PATCH
|
||||
#include "dragcfact.c"
|
||||
#endif
|
||||
#if DWMBLOCKS_PATCH && STATUSCMD_PATCH
|
||||
#include "dwmblocks.c"
|
||||
#endif
|
||||
#if DWMC_PATCH
|
||||
#include "dwmc.c"
|
||||
#elif FSIGNAL_PATCH
|
||||
|
@@ -32,6 +32,9 @@
|
||||
#if DRAGMFACT_PATCH
|
||||
#include "dragmfact.h"
|
||||
#endif
|
||||
#if DWMBLOCKS_PATCH && STATUSCMD_PATCH
|
||||
#include "dwmblocks.h"
|
||||
#endif
|
||||
#if DWMC_PATCH
|
||||
#include "dwmc.h"
|
||||
#elif FSIGNAL_PATCH
|
||||
|
Reference in New Issue
Block a user