Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve shebangs, kill command #196

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions chadwm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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} $<
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion chadwm/config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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} },
Expand Down
4 changes: 2 additions & 2 deletions chadwm/config.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# dwm version
VERSION = 6.4
VERSION = 6.5

# Customize below to fit your system

Expand All @@ -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}
Expand Down
49 changes: 30 additions & 19 deletions chadwm/dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/bar.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/dash
#!/usr/bin/env dash

# ^c$var^ = fg color
# ^b$var^ = bg color
Expand Down
3 changes: 2 additions & 1 deletion scripts/fetch
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

clear
c=3 b=4
for j in c b; do
Expand Down
4 changes: 2 additions & 2 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
#!/usr/bin/env sh

xrdb merge ~/.Xresources
xbacklight -set 10 &
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