sxalert

Simple notification system for X
git clone git://mcdim.xyz/sxalert.git
Log | Files | Refs | README | LICENSE

wal.diff (1612B)


      1 --- ../sxalert_simplification_attempt/config.h	2026-09-19 00:57:10.187027307 +0300
      2 +++ config.h	2026-09-19 01:23:35.202912393 +0300
      3 @@ -29,3 +29,5 @@
      4  	.font		= "DejaVu Sans Mono:size=13:antialias=true",
      5  	.text_height 	= 10,
      6  };
      7 +
      8 +const char *xresources = "/home/michael/.cache/wal/colors.Xresources"; /* wal */
      9 --- ../sxalert_simplification_attempt/sxalert.h	2026-09-01 15:36:58.132156170 +0300
     10 +++ sxalert.h	2026-09-19 01:23:11.668554392 +0300
     11 @@ -1,6 +1,8 @@
     12  #ifndef SXALERT_H
     13  #define SXALERT_H
     14  
     15 +#define XR_BUFFER 128
     16 +
     17  struct alert {
     18  	int duration;
     19  	char text_color[7];
     20 --- ../sxalert_simplification_attempt/sxalert.c	2026-09-19 00:59:47.056450915 +0300
     21 +++ sxalert.c	2026-09-19 01:19:07.926615607 +0300
     22 @@ -63,6 +63,40 @@
     23  	return max;
     24  }
     25  
     26 +void
     27 +get_xresources_colors(struct alert *a)
     28 +{
     29 +	FILE *f = fopen(xresources, "r");
     30 +	if (!f) {
     31 +		fprintf(stderr, "Could not open file: %s\n", xresources);
     32 +		exit(EXIT_FAILURE);
     33 +	}
     34 +
     35 +	char buffer[XR_BUFFER];
     36 +
     37 +	char colors[2][8];
     38 +	int clr_i=0;
     39 +
     40 +	char *arr[2];
     41 +
     42 +	for (int i=0; i<4; i++) {
     43 +		fgets(buffer, sizeof(buffer), f);
     44 +
     45 +		if (i <= 1) continue;
     46 +
     47 +		arr[0] = strtok(buffer, "#");
     48 +		arr[1] = strtok(NULL, "#\n");
     49 +
     50 +		strncpy(colors[clr_i++], arr[1], 7);
     51 +	}
     52 +
     53 +	strcpy(a->text_color, colors[0]);
     54 +	strcpy(a->border_color, colors[0]);
     55 +	strcpy(a->bg_color, colors[1]);
     56 +
     57 +	fclose(f);
     58 +}
     59 +
     60  static int
     61  get_width(Display *dpy, XftFont *font, struct alert *a)
     62  {
     63 @@ -258,6 +292,8 @@
     64  
     65  	struct alert a = default_alert;
     66  
     67 +	get_xresources_colors(&a);
     68 +
     69  	while ((c = getopt(argc, argv, "d:b:t:g:r:vh")) != -1 ) {
     70  		switch (c) {
     71  		case 'v':