Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
5705e8b3cc |
7 changed files with 48 additions and 4 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
|||
st.o
|
||||
|
||||
st
|
||||
x.o
|
||||
config.h
|
||||
*.o
|
||||
*.orig
|
||||
*.rej
|
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@
|
|||
|
||||
include config.mk
|
||||
|
||||
SRC = st.c x.c
|
||||
SRC = st.c x.c colors.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
all: st
|
||||
|
|
39
colors.c
Normal file
39
colors.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#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);
|
||||
}
|
2
colors.h
Normal file
2
colors.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
void colorpywal(void);
|
|
@ -97,7 +97,7 @@ unsigned int tabspaces = 8;
|
|||
float alpha = 0.8;
|
||||
|
||||
/* Terminal colors (16 first used in escape sequence) */
|
||||
static const char *colorname[] = {
|
||||
char *colorname[] = {
|
||||
/* 8 normal colors */
|
||||
"black",
|
||||
"red3",
|
||||
|
|
1
st.c
1
st.c
|
@ -1360,6 +1360,7 @@ tdeleteline(int n)
|
|||
tscrollup(term.c.y, n, 0);
|
||||
}
|
||||
|
||||
|
||||
int32_t
|
||||
tdefcolor(const int *attr, int *npar, int l)
|
||||
{
|
||||
|
|
2
x.c
2
x.c
|
@ -17,6 +17,7 @@
|
|||
|
||||
char *argv0;
|
||||
#include "arg.h"
|
||||
#include "colors.h"
|
||||
#include "st.h"
|
||||
#include "win.h"
|
||||
|
||||
|
@ -771,6 +772,7 @@ sixd_to_16bit(int x)
|
|||
int
|
||||
xloadcolor(int i, const char *name, Color *ncolor)
|
||||
{
|
||||
colorpywal();
|
||||
XRenderColor color = { .alpha = 0xffff };
|
||||
|
||||
if (!name) {
|
||||
|
|
Loading…
Reference in a new issue