aports

Custom Alpine Linux aports

git clone https://git.8pit.net/aports.git

 1From 55b1fdbf5f1a7d9987d22ae65cfc39fbb2bb2958 Mon Sep 17 00:00:00 2001
 2From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
 3Date: Thu, 15 Feb 2024 17:36:56 +0100
 4Subject: [PATCH] Compile without X11, print text to standard output
 5
 6---
 7 GNUmakefile  |  8 ++------
 8 dwm-status.c | 12 ++----------
 9 2 files changed, 4 insertions(+), 16 deletions(-)
10
11diff --git a/GNUmakefile b/GNUmakefile
12index ce232d5..783de68 100644
13--- a/GNUmakefile
14+++ b/GNUmakefile
15@@ -4,17 +4,13 @@ BIN_NAME = dwm-status
16 OBJECTS = $(BIN_NAME).o
17 HEADERS = config.h
18 
19-X11INC ?= /usr/include/X11
20-X11LIB ?= /usr/lib/X11
21-
22 CFLAGS ?= -O0 -g -Werror
23-CFLAGS += -D_BSD_SOURCE -std=c99
24+CFLAGS += -D_DEFAULT_SOURCE -std=c99
25 CFLAGS += -Wpedantic -Wall -Wextra \
26 	      -Wmissing-prototypes -Wpointer-arith \
27 	      -Wstrict-prototypes -Wshadow
28 
29-CPPFLAGS += -I$(X11INC)
30-LDFLAGS  += -L$(X11LIB) -lX11 -ltinyalsa
31+LDFLAGS += -ltinyalsa
32 
33 %.o: %.c $(HEADERS)
34 	$(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
35diff --git a/dwm-status.c b/dwm-status.c
36index 8e15a90..0afbe8f 100644
37--- a/dwm-status.c
38+++ b/dwm-status.c
39@@ -11,7 +11,6 @@
40 #include <unistd.h>
41 
42 #include <sys/types.h>
43-#include <X11/Xlib.h>
44 #include <tinyalsa/asoundlib.h>
45 
46 static size_t alsavol(char*, size_t);
47@@ -171,14 +170,8 @@ separator(char *dest, size_t n)
48 int
49 main(void)
50 {
51-	Display *dpy;
52-	Window root;
53 	size_t i, x, fns, max;
54 
55-	if (!(dpy = XOpenDisplay(NULL)))
56-		errx(EXIT_FAILURE, "couldn't open display '%s'", XDisplayName(NULL));
57-	root = DefaultRootWindow(dpy);
58-
59 	max = STATUSSZ - 1;
60 	fns = sizeof(sfuncs) / sizeof(sfuncs[0]);
61 
62@@ -191,11 +184,10 @@ main(void)
63 		assert(x < STATUSSZ);
64 		ststr[x] = '\0';
65 
66-		XStoreName(dpy, root, ststr);
67-		XSync(dpy, False);
68+		printf("%s\n", ststr);
69+		fflush(stdout);
70 		sleep(delay);
71 	}
72 
73-	XCloseDisplay(dpy);
74 	return EXIT_SUCCESS;
75 }