sxalert

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

wal.diff (1413B)


      1 --- sxalert.c	2023-11-18 13:24:57.322378330 +0000
      2 +++ sxalertxr.c	2023-11-18 13:24:26.619213478 +0000
      3 @@ -70,6 +70,40 @@
      4  	return max;
      5  }
      6  
      7 +void
      8 +get_xresources_colors(void)
      9 +{
     10 +	FILE *f = fopen(xresources, "r");
     11 +	if (!f) {
     12 +		fprintf(stderr, "Could not open file: %s\n", xresources);
     13 +		exit(EXIT_FAILURE);
     14 +	}
     15 +
     16 +	char buffer[XR_BUFFER];
     17 +
     18 +	char colors[2][8];
     19 +	int clr_i=0;
     20 +
     21 +	char *arr[2];
     22 +
     23 +	for (int i=0; i<4; i++) {
     24 +		fgets(buffer, sizeof(buffer), f);
     25 +
     26 +		if (i <= 1) continue;
     27 +
     28 +		arr[0] = strtok(buffer, "#");
     29 +		arr[1] = strtok(NULL, "#\n");
     30 +
     31 +		strncpy(colors[clr_i++], arr[1], 7);
     32 +	}
     33 +
     34 +	strcpy(text_color, colors[0]);
     35 +	strcpy(border_color, colors[0]);
     36 +	strcpy(bg_color, colors[1]);
     37 +
     38 +	fclose(f);
     39 +}
     40 +
     41  static int
     42  get_width(Display *dpy, XftFont *font, char **lines, int length)
     43  {
     44 @@ -176,6 +210,8 @@
     45  	char text[BUFFER];
     46  	extern char *optarg;
     47  
     48 +	get_xresources_colors();
     49 +
     50  	while ((c = getopt(argc, argv, "d:b:t:g:r:vh")) != -1 ) {
     51  		switch (c) {
     52  		case 'v':
     53 --- config.h	2023-11-18 13:25:05.212335034 +0000
     54 +++ configxr.h	2023-11-18 13:19:15.637586640 +0000
     55 @@ -6,6 +6,7 @@
     56   */
     57  
     58  #define BUFFER 2054
     59 +#define XR_BUFFER 128
     60  
     61  static int duration = 5000; /* in milliseconds */
     62  
     63 @@ -26,3 +27,5 @@
     64  
     65  const char *fontname = "DejaVu Sans Mono:size=13:antialias=true";
     66  static int text_height = 11;
     67 +
     68 +const char *xresources = "/home/$USER/.cache/wal/colors.Xresources"; /* wal */