Did some cleanup
This commit is contained in:
parent
93c80d538a
commit
b0747006c6
17
Makefile
17
Makefile
|
@ -1,24 +1,25 @@
|
||||||
#PREFIX = /usr/local
|
#PREFIX = /usr/local
|
||||||
PREFIX = ${HOME}/.local
|
PREFIX = ${HOME}/.local
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra -Os
|
CFLAGS = -Wall -Wextra -Wextra -O3
|
||||||
CFLAGSEXTRA = -Wno-unused-parameter -Wno-missing-field-initializers
|
CFLAGSEXTRA = -Wno-unused-parameter -Wno-missing-field-initializers
|
||||||
|
|
||||||
build: dwmblocks sigdwmblocks
|
all: dwmblocks sigdwmblocks
|
||||||
|
|
||||||
dwmblocks: dwmblocks.c blocks.h
|
dwmblocks: dwmblocks.c
|
||||||
${CC} ${CFLAGS} ${CFLAGSEXTRA} -lX11 dwmblocks.c -o dwmblocks
|
${CC} -o $@ -lX11 ${CFLAGS} ${CFLAGSEXTRA} $<
|
||||||
|
|
||||||
sigdwmblocks: sigdwmblocks.c
|
sigdwmblocks: sigdwmblocks.c
|
||||||
${CC} ${CFLAGS} sigdwmblocks.c -o sigdwmblocks
|
${CC} -o $@ ${CFLAGS} sigdwmblocks.c
|
||||||
|
|
||||||
xgetrootname: xgetrootname.c
|
xgetrootname: xgetrootname.c
|
||||||
${CC} ${CFLAGS} xgetrootname.c -o xgetrootname
|
${CC} -o $@ -lX11 ${CFLAGS} xgetrootname.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f dwmblocks sigdwmblocks
|
rm -f dwmblocks sigdwmblocks
|
||||||
|
|
||||||
install: build
|
install: all
|
||||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
install -m 0755 dwmblocks ${DESTDIR}${PREFIX}/bin/dwmblocks
|
install -m 0755 dwmblocks ${DESTDIR}${PREFIX}/bin/dwmblocks
|
||||||
install -m 0755 sigdwmblocks ${DESTDIR}${PREFIX}/bin/sigdwmblocks
|
install -m 0755 sigdwmblocks ${DESTDIR}${PREFIX}/bin/sigdwmblocks
|
||||||
|
@ -26,4 +27,4 @@ install: build
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f ${DESTDIR}${PREFIX}/bin/dwmblocks ${DESTDIR}${PREFIX}/bin/sigdwmblocks
|
rm -f ${DESTDIR}${PREFIX}/bin/dwmblocks ${DESTDIR}${PREFIX}/bin/sigdwmblocks
|
||||||
|
|
||||||
.PHONY: build clean install uninstall
|
.PHONY: all clean install uninstall
|
||||||
|
|
|
@ -39,7 +39,7 @@ the block.
|
||||||
|
|
||||||
# xgetrootname
|
# 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.
|
debugging.
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
14
dwmblocks.c
14
dwmblocks.c
|
@ -27,7 +27,7 @@ static void buttonhandler(int signal, siginfo_t *si, void *ucontext);
|
||||||
static void getcmd(Block *block, int *sigval);
|
static void getcmd(Block *block, int *sigval);
|
||||||
static void setroot();
|
static void setroot();
|
||||||
static void setupsignals();
|
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 statusloop();
|
||||||
static void termhandler(int signum);
|
static void termhandler(int signum);
|
||||||
static int updatestatus();
|
static int updatestatus();
|
||||||
|
@ -39,7 +39,6 @@ static int statusContinue = 1;
|
||||||
static char statusstr[STTLENGTH];
|
static char statusstr[STTLENGTH];
|
||||||
static size_t delimlength;
|
static size_t delimlength;
|
||||||
static Display *dpy;
|
static Display *dpy;
|
||||||
static Window root;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
buttonhandler(int signal, siginfo_t *si, void *ucontext)
|
buttonhandler(int signal, siginfo_t *si, void *ucontext)
|
||||||
|
@ -115,7 +114,7 @@ setroot()
|
||||||
{
|
{
|
||||||
if (updatestatus()) /* only set root if block outputs have changed */
|
if (updatestatus()) /* only set root if block outputs have changed */
|
||||||
return;
|
return;
|
||||||
XStoreName(dpy, root, statusstr);
|
XStoreName(dpy, DefaultRootWindow(dpy), statusstr);
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,11 +150,11 @@ setupsignals()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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++) {
|
for (Block *current = blocks; current->pathu; current++) {
|
||||||
if (current->signal == signum)
|
if (current->signal == signal)
|
||||||
getcmd(current, &(si->si_value.sival_int));
|
getcmd(current, &(si->si_value.sival_int));
|
||||||
}
|
}
|
||||||
setroot();
|
setroot();
|
||||||
|
@ -294,10 +293,9 @@ main(int argc, char *argv[])
|
||||||
fputs("Error: could not open display.\n", stderr);
|
fputs("Error: could not open display.\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
root = RootWindow(dpy, DefaultScreen(dpy));
|
|
||||||
statusloop();
|
statusloop();
|
||||||
unlink(LOCKFILE);
|
unlink(LOCKFILE);
|
||||||
XStoreName(dpy, root, "");
|
XStoreName(dpy, DefaultRootWindow(dpy), "");
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
BIN
xgetrootname
BIN
xgetrootname
Binary file not shown.
|
@ -5,15 +5,13 @@ int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
Window root;
|
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (!(dpy = XOpenDisplay(NULL))) {
|
if (!(dpy = XOpenDisplay(NULL))) {
|
||||||
fputs("Error: could not open display.\n", stderr);
|
fputs("Error: could not open display.\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
root = RootWindow(dpy, DefaultScreen(dpy));
|
if (XFetchName(dpy, DefaultRootWindow(dpy), &name) && name[0])
|
||||||
if (XFetchName(dpy, root, &name) && name[0])
|
|
||||||
printf("%s\n", name);
|
printf("%s\n", name);
|
||||||
else
|
else
|
||||||
puts("No name has been set for the root window.");
|
puts("No name has been set for the root window.");
|
||||||
|
|
Loading…
Reference in a new issue