39 lines
No EOL
1.1 KiB
C
39 lines
No EOL
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
// Declare the colorname array (defined in config.h)
|
|
extern char *colorname[];
|
|
|
|
void colorpywal() {
|
|
const char *home_dir = getenv("HOME");
|
|
if (home_dir == NULL) {
|
|
fprintf(stderr, "Error: Could not determine home directory.\n");
|
|
return;
|
|
} else {
|
|
fprintf(stdout, "Debug: Found Home Directory.\n");
|
|
}
|
|
|
|
// Construct the path to the Pywal colors file
|
|
char pywal_colors_path[256];
|
|
snprintf(pywal_colors_path, sizeof(pywal_colors_path), "%s/.cache/wal/colors", home_dir);
|
|
fprintf(stdout, "Debug: PyWal Path: %s", pywal_colors_path);
|
|
FILE *fp = fopen(pywal_colors_path, "r");
|
|
if (fp == NULL) {
|
|
// Pywal colors file not found, do nothing
|
|
return;
|
|
}
|
|
|
|
char line[256];
|
|
int i = 0;
|
|
|
|
// Read colors from the file and update the colorname array
|
|
while (fgets(line, sizeof(line), fp) != NULL && i < 16) {
|
|
line[strcspn(line, "\n")] = 0; // Remove newline character
|
|
colorname[i] = strdup(line); // Duplicate the color string
|
|
i++;
|
|
}
|
|
|
|
// Clean up
|
|
fclose(fp);
|
|
} |