Skip to content

Commit

Permalink
merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuehrer committed Mar 14, 2021
2 parents 73fd031 + 7892511 commit 1697346
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 8 additions & 3 deletions dwmblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand Down

0 comments on commit 1697346

Please sign in to comment.