diff --git a/chadwm/Makefile b/chadwm/Makefile index 247c18ee..ebcc5c04 100644 --- a/chadwm/Makefile +++ b/chadwm/Makefile @@ -6,13 +6,7 @@ include config.mk SRC = drw.c dwm.c util.c OBJ = ${SRC:.c=.o} -all: options dwm - -options: - @echo dwm build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" +all: dwm .c.o: ${CC} -c ${CFLAGS} $< @@ -48,4 +42,4 @@ uninstall: rm -f ${DESTDIR}${PREFIX}/bin/chadwm\ ${DESTDIR}${MANPREFIX}/man1/dwm.1 -.PHONY: all options clean dist install uninstall +.PHONY: all clean dist install uninstall diff --git a/chadwm/config.def.h b/chadwm/config.def.h index 99f08098..9458572a 100644 --- a/chadwm/config.def.h +++ b/chadwm/config.def.h @@ -227,7 +227,7 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_w, setborderpx, {.i = default_border } }, // kill dwm - { MODKEY|ControlMask, XK_q, spawn, SHCMD("killall bar.sh chadwm") }, + { MODKEY|ControlMask, XK_q, spawn, SHCMD("pkill -f [c]hadwm/scripts/bar.sh ; pkill -x chadwm") }, // kill window { MODKEY, XK_q, killclient, {0} }, diff --git a/chadwm/config.mk b/chadwm/config.mk index 18af5189..6b617c4a 100644 --- a/chadwm/config.mk +++ b/chadwm/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = 6.4 +VERSION = 6.5 # Customize below to fit your system @@ -26,7 +26,7 @@ INCS = -I${X11INC} -I${FREETYPEINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2 # flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -O3 -march=native ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} diff --git a/chadwm/dwm.c b/chadwm/dwm.c index ddb7e0c5..041d6a57 100644 --- a/chadwm/dwm.c +++ b/chadwm/dwm.c @@ -320,7 +320,6 @@ static void seturgent(Client *c, int urg); static void show(Client *c); static void showhide(Client *c); static void showtagpreview(int tag); -static void sigchld(int unused); static void spawn(const Arg *arg); static void switchtag(void); static Monitor *systraytomon(Monitor *m); @@ -1923,17 +1922,26 @@ void grabbuttons(Client *c, int focused) { void grabkeys(void) { updatenumlockmask(); { - unsigned int i, j; + unsigned int i, j, k; unsigned int modifiers[] = {0, LockMask, numlockmask, numlockmask | LockMask}; - KeyCode code; - + int start, end, skip; + KeySym *syms; XUngrabKey(dpy, AnyKey, AnyModifier, root); - for (i = 0; i < LENGTH(keys); i++) - if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) - for (j = 0; j < LENGTH(modifiers); j++) - XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, True, - GrabModeAsync, GrabModeAsync); + XDisplayKeycodes(dpy, &start, &end); + syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip); + if (!syms) + return; + for (k = start; k <= end; k++) + for (i = 0; i < LENGTH(keys); i++) + /* skip modifier codes, we do that ourselves */ + if (keys[i].keysym == syms[(k - start) * skip]) + for (j = 0; j < LENGTH(modifiers); j++) + XGrabKey(dpy, k, + keys[i].mod | modifiers[j], + root, True, + GrabModeAsync, GrabModeAsync); + XFree(syms); } } @@ -2877,9 +2885,15 @@ void setup(void) { int i; XSetWindowAttributes wa; Atom utf8string; + struct sigaction sa; + /* do not transform children into zombies when they terminate */ + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART; + sa.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &sa, NULL); - /* clean up any zombies immediately */ - sigchld(0); + /* clean up any zombies (inherited from .xinitrc etc) immediately */ + while (waitpid(-1, NULL, WNOHANG) > 0); /* init screen */ screen = DefaultScreen(dpy); @@ -3035,19 +3049,16 @@ showtagpreview(int tag) } -void sigchld(int unused) { - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("can't install SIGCHLD handler:"); - while (0 < waitpid(-1, NULL, WNOHANG)) - ; -} - - void spawn(const Arg *arg) { + struct sigaction sa; if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy)); setsid(); + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &sa, NULL); execvp(((char **)arg->v)[0], (char **)arg->v); die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]); } diff --git a/scripts/bar.sh b/scripts/bar.sh index 7f98d652..dcf29ab9 100755 --- a/scripts/bar.sh +++ b/scripts/bar.sh @@ -1,4 +1,4 @@ -#!/bin/dash +#!/usr/bin/env dash # ^c$var^ = fg color # ^b$var^ = bg color diff --git a/scripts/fetch b/scripts/fetch index cfa60642..b9d1d5a6 100755 --- a/scripts/fetch +++ b/scripts/fetch @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + clear c=3 b=4 for j in c b; do diff --git a/scripts/run.sh b/scripts/run.sh index ca79cc75..e3d1a05c 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh xrdb merge ~/.Xresources xbacklight -set 10 & @@ -6,5 +6,5 @@ feh --bg-fill ~/Pictures/wall/gruv.png & xset r rate 200 50 & picom & -dash ~/.config/chadwm/scripts/bar.sh & +~/.config/chadwm/scripts/bar.sh & while type chadwm >/dev/null; do chadwm && continue || break; done