merged with master
This commit is contained in:
commit
1697346729
4 changed files with 14 additions and 14 deletions
9
Makefile
9
Makefile
|
@ -1,14 +1,15 @@
|
|||
.POSIX:
|
||||
|
||||
PREFIX = /usr/local
|
||||
CC = gcc
|
||||
|
||||
output: dwmblocks.o
|
||||
gcc dwmblocks.o -lX11 -o dwmblocks
|
||||
dwmblocks: dwmblocks.o
|
||||
$(CC) dwmblocks.o -lX11 -o dwmblocks
|
||||
dwmblocks.o: dwmblocks.c config.h
|
||||
gcc -c -lX11 dwmblocks.c
|
||||
$(CC) -c dwmblocks.c
|
||||
clean:
|
||||
rm -f *.o *.gch dwmblocks
|
||||
install: output
|
||||
install: dwmblocks
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f dwmblocks $(DESTDIR)$(PREFIX)/bin
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/dwmblocks
|
||||
|
|
|
@ -31,9 +31,7 @@ but is faster. Just add 34 to your typical signal number.
|
|||
My volume module *never* updates on its own, instead I have this command run
|
||||
along side my volume shortcuts in dwm to only update it when relevant.
|
||||
|
||||
Note that if you signal an unexpected signal to dwmblocks, it will probably
|
||||
crash. So if you disable a module, remember to also disable any cronjobs or
|
||||
other scripts that might signal to that module.
|
||||
Note that all modules must have different signal numbers.
|
||||
|
||||
# Clickable modules
|
||||
|
||||
|
|
4
config.h
4
config.h
|
@ -14,7 +14,3 @@ static const Block blocks[] = {
|
|||
{"", "battery", 5, 3},
|
||||
{"", "clock", 1, 1},
|
||||
};
|
||||
|
||||
//sets delimeter between status commands. NULL character ('\0') means no delimeter.
|
||||
static char *delim = "|";
|
||||
|
||||
|
|
11
dwmblocks.c
11
dwmblocks.c
|
@ -114,6 +114,10 @@ void getsigcmds(int signal)
|
|||
void setupsignals()
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
for(int i = SIGRTMIN; i <= SIGRTMAX; i++)
|
||||
signal(i, SIG_IGN);
|
||||
|
||||
for(int i = 0; i < LENGTH(blocks); i++)
|
||||
{
|
||||
if (blocks[i].signal > 0)
|
||||
|
@ -210,6 +214,7 @@ void sighandler(int signum)
|
|||
void buttonhandler(int sig, siginfo_t *si, void *ucontext)
|
||||
{
|
||||
char button[2] = {'0' + si->si_value.sival_int & 0xff, '\0'};
|
||||
pid_t process_id = getpid();
|
||||
sig = si->si_value.sival_int >> 8;
|
||||
if (fork() == 0)
|
||||
{
|
||||
|
@ -220,14 +225,14 @@ void buttonhandler(int sig, siginfo_t *si, void *ucontext)
|
|||
if (current->signal == sig)
|
||||
break;
|
||||
}
|
||||
char *command[] = { "/bin/sh", "-c", current->command, NULL };
|
||||
char shcmd[1024];
|
||||
sprintf(shcmd,"%s && kill -%d %d",current->command, current->signal+34,process_id);
|
||||
char *command[] = { "/bin/sh", "-c", shcmd, NULL };
|
||||
setenv("BLOCK_BUTTON", button, 1);
|
||||
setsid();
|
||||
execvp(command[0], command);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
getsigcmds(sig);
|
||||
writestatus();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue