sxalert-1.0-xresources.diff (1644B)
1 diff -ruN old/config.h new/config.h 2 --- old/config.h 2026-10-15 02:27:36.895141358 +0300 3 +++ new/config.h 2026-10-15 02:22:29.877680526 +0300 4 @@ -28,3 +28,5 @@ 5 .font = "DejaVu Sans Mono:size=13:antialias=true", 6 .text_height = 10, 7 }; 8 + 9 +const char *xresources = "/home/michael/.cache/wal/colors.Xresources"; /* wal */ 10 diff -ruN old/sxalert.c new/sxalert.c 11 --- old/sxalert.c 2026-10-15 02:27:29.337141729 +0300 12 +++ new/sxalert.c 2026-10-15 02:24:51.835149470 +0300 13 @@ -66,6 +66,40 @@ 14 return max; 15 } 16 17 +static void 18 +get_xresources_colors(struct alert *a) 19 +{ 20 + FILE *f = fopen(xresources, "r"); 21 + if (!f) { 22 + fprintf(stderr, "Could not open file: %s\n", xresources); 23 + exit(EXIT_FAILURE); 24 + } 25 + 26 + char buffer[XR_BUFFER]; 27 + 28 + char colors[2][8]; 29 + int clr_i=0; 30 + 31 + char *arr[2]; 32 + 33 + for (int i=0; i<4; i++) { 34 + fgets(buffer, sizeof(buffer), f); 35 + 36 + if (i <= 1) continue; 37 + 38 + arr[0] = strtok(buffer, "#"); 39 + arr[1] = strtok(NULL, "#\n"); 40 + 41 + strncpy(colors[clr_i++], arr[1], 7); 42 + } 43 + 44 + strcpy(a->text_color, colors[0]); 45 + strcpy(a->border_color, colors[0]); 46 + strcpy(a->bg_color, colors[1]); 47 + 48 + fclose(f); 49 +} 50 + 51 static int 52 get_width(Display *dpy, XftFont *font, struct alert *a) 53 { 54 @@ -301,6 +335,8 @@ 55 if (flock(fd, LOCK_EX) == -1) 56 return 1; 57 58 + get_xresources_colors(&a); 59 + 60 int cmd_lines_len = argc - optind; 61 char **lines = argv + optind; 62 63 diff -ruN old/sxalert.h new/sxalert.h 64 --- old/sxalert.h 2026-10-15 02:27:32.357141581 +0300 65 +++ new/sxalert.h 2026-10-15 02:22:29.877893651 +0300 66 @@ -7,6 +7,8 @@ 67 #ifndef SXALERT_H 68 #define SXALERT_H 69 70 +#define XR_BUFFER 128 71 + 72 struct alert { 73 int duration; 74 char text_color[7];