Did some cleanup

This commit is contained in:
Ashish Kumar Yadav 2020-07-07 01:58:41 +05:30
parent 93c80d538a
commit b0747006c6
5 changed files with 17 additions and 20 deletions

View File

@ -1,24 +1,25 @@
#PREFIX = /usr/local
PREFIX = ${HOME}/.local
CC = gcc
CFLAGS = -Wall -Wextra -Os
CFLAGS = -Wall -Wextra -Wextra -O3
CFLAGSEXTRA = -Wno-unused-parameter -Wno-missing-field-initializers
build: dwmblocks sigdwmblocks
all: dwmblocks sigdwmblocks
dwmblocks: dwmblocks.c blocks.h
${CC} ${CFLAGS} ${CFLAGSEXTRA} -lX11 dwmblocks.c -o dwmblocks
dwmblocks: dwmblocks.c
${CC} -o $@ -lX11 ${CFLAGS} ${CFLAGSEXTRA} $<
sigdwmblocks: sigdwmblocks.c
${CC} ${CFLAGS} sigdwmblocks.c -o sigdwmblocks
${CC} -o $@ ${CFLAGS} sigdwmblocks.c
xgetrootname: xgetrootname.c
${CC} ${CFLAGS} xgetrootname.c -o xgetrootname
${CC} -o $@ -lX11 ${CFLAGS} xgetrootname.c
clean:
rm -f dwmblocks sigdwmblocks
install: build
install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
install -m 0755 dwmblocks ${DESTDIR}${PREFIX}/bin/dwmblocks
install -m 0755 sigdwmblocks ${DESTDIR}${PREFIX}/bin/sigdwmblocks
@ -26,4 +27,4 @@ install: build
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwmblocks ${DESTDIR}${PREFIX}/bin/sigdwmblocks
.PHONY: build clean install uninstall
.PHONY: all clean install uninstall

View File

@ -39,7 +39,7 @@ the block.
# xgetrootname
It is a small program to get the current root name. May prove helpful in
It is a tiny program to get the current root name. May prove helpful in
debugging.
# Installation

View File

@ -27,7 +27,7 @@ static void buttonhandler(int signal, siginfo_t *si, void *ucontext);
static void getcmd(Block *block, int *sigval);
static void setroot();
static void setupsignals();
static void sighandler(int signum, siginfo_t *si, void *ucontext);
static void sighandler(int signal, siginfo_t *si, void *ucontext);
static void statusloop();
static void termhandler(int signum);
static int updatestatus();
@ -39,7 +39,6 @@ static int statusContinue = 1;
static char statusstr[STTLENGTH];
static size_t delimlength;
static Display *dpy;
static Window root;
void
buttonhandler(int signal, siginfo_t *si, void *ucontext)
@ -115,7 +114,7 @@ setroot()
{
if (updatestatus()) /* only set root if block outputs have changed */
return;
XStoreName(dpy, root, statusstr);
XStoreName(dpy, DefaultRootWindow(dpy), statusstr);
XFlush(dpy);
}
@ -151,11 +150,11 @@ setupsignals()
}
void
sighandler(int signum, siginfo_t *si, void *ucontext)
sighandler(int signal, siginfo_t *si, void *ucontext)
{
signum -= SIGRTMIN;
signal -= SIGRTMIN;
for (Block *current = blocks; current->pathu; current++) {
if (current->signal == signum)
if (current->signal == signal)
getcmd(current, &(si->si_value.sival_int));
}
setroot();
@ -294,10 +293,9 @@ main(int argc, char *argv[])
fputs("Error: could not open display.\n", stderr);
return 1;
}
root = RootWindow(dpy, DefaultScreen(dpy));
statusloop();
unlink(LOCKFILE);
XStoreName(dpy, root, "");
XStoreName(dpy, DefaultRootWindow(dpy), "");
XCloseDisplay(dpy);
return 0;
}

Binary file not shown.

View File

@ -5,15 +5,13 @@ int
main()
{
Display *dpy;
Window root;
char *name;
if (!(dpy = XOpenDisplay(NULL))) {
fputs("Error: could not open display.\n", stderr);
return 1;
}
root = RootWindow(dpy, DefaultScreen(dpy));
if (XFetchName(dpy, root, &name) && name[0])
if (XFetchName(dpy, DefaultRootWindow(dpy), &name) && name[0])
printf("%s\n", name);
else
puts("No name has been set for the root window.");