Add darkman patch
a patch to choose between two color themes by executing a command
This commit is contained in:
parent
d44ab2a9a2
commit
48defe07d2
3 changed files with 74 additions and 3 deletions
38
config.def.h
38
config.def.h
|
|
@ -212,6 +212,44 @@ static const char *colorname[] = {
|
||||||
"#e5e5e5", /* 259 -> fg */
|
"#e5e5e5", /* 259 -> fg */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if DARKMAN_PATCH
|
||||||
|
#define colorname_len (sizeof(colorname) / sizeof(char *))
|
||||||
|
|
||||||
|
enum theme {
|
||||||
|
THEME_LIGHT,
|
||||||
|
THEME_DARK,
|
||||||
|
THEME_NUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Terminal colors (16 first used in escape sequence) */
|
||||||
|
static const char *colornames[THEME_NUM][colorname_len] = {
|
||||||
|
{ }, {
|
||||||
|
"#1a1a1a", /* hard contrast: #1d2021 / soft contrast: #32302f */
|
||||||
|
"#f4005f",
|
||||||
|
"#98e024",
|
||||||
|
"#fa8419",
|
||||||
|
"#9d65ff",
|
||||||
|
"#f4005f",
|
||||||
|
"#58d1eb",
|
||||||
|
"#c4c5b5",
|
||||||
|
"#625e4c",
|
||||||
|
"#f4005f",
|
||||||
|
"#98e024",
|
||||||
|
"#e0d561",
|
||||||
|
"#9d65ff",
|
||||||
|
"#f4005f",
|
||||||
|
"#58d1eb",
|
||||||
|
"#f6f6ef",
|
||||||
|
[255] = 0,
|
||||||
|
/* more colors can be added after 255 to use with DefaultXX */
|
||||||
|
"#aaaaaa", /* 256 -> cursor */
|
||||||
|
"#555555", /* 257 -> rev cursor*/
|
||||||
|
"#000000", /* 258 -> bg */
|
||||||
|
"#ffffff", /* 259 -> fg */
|
||||||
|
}};
|
||||||
|
|
||||||
|
#endif // DARKMAN_PATCH
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default colors (colorname index)
|
* Default colors (colorname index)
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,9 @@
|
||||||
*/
|
*/
|
||||||
#define FONTFEATURES_PATCH 1
|
#define FONTFEATURES_PATCH 1
|
||||||
|
|
||||||
|
#define DARKMAN_PATCH 1
|
||||||
|
|
||||||
|
|
||||||
/* This patch makes st ignore terminal color attributes by forcing display of the default
|
/* This patch makes st ignore terminal color attributes by forcing display of the default
|
||||||
* foreground and background colors only - making for a monochrome look. Idea ref.
|
* foreground and background colors only - making for a monochrome look. Idea ref.
|
||||||
* https://www.reddit.com/r/suckless/comments/ixbx6z/how_to_use_black_and_white_only_for_st/
|
* https://www.reddit.com/r/suckless/comments/ixbx6z/how_to_use_black_and_white_only_for_st/
|
||||||
|
|
|
||||||
36
x.c
36
x.c
|
|
@ -802,10 +802,13 @@ setsel(char *str, Time t)
|
||||||
#endif // CLIPBOARD_PATCH
|
#endif // CLIPBOARD_PATCH
|
||||||
}
|
}
|
||||||
|
|
||||||
#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH
|
#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH || DARKMAN_PATCH
|
||||||
void
|
void
|
||||||
sigusr1_reload(int sig)
|
sigusr1_reload(int sig)
|
||||||
{
|
{
|
||||||
|
#if DARKMAN_PATCH
|
||||||
|
xloadcols();
|
||||||
|
#endif // DARKMAN_PATCH
|
||||||
#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH
|
#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH
|
||||||
reload_config(sig);
|
reload_config(sig);
|
||||||
#endif // XRESOURCES_RELOAD_PATCH
|
#endif // XRESOURCES_RELOAD_PATCH
|
||||||
|
|
@ -988,6 +991,28 @@ xloadalpha(void)
|
||||||
}
|
}
|
||||||
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||||
|
|
||||||
|
#if DARKMAN_PATCH
|
||||||
|
void
|
||||||
|
darkmanThemeChoose() {
|
||||||
|
FILE *fp;
|
||||||
|
char path[128];
|
||||||
|
|
||||||
|
fp = popen("darkman get", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
memcpy(colorname, colornames[0], sizeof(colorname));
|
||||||
|
} else {
|
||||||
|
/* match the stdout with the theme */
|
||||||
|
while (fgets(path, sizeof(path)-1, fp) != NULL) {
|
||||||
|
if (strcmp(path, "light\n") == 0) {
|
||||||
|
memcpy(colorname, colornames[0], sizeof(colorname));
|
||||||
|
} else if (strcmp(path, "dark\n") == 0) {
|
||||||
|
memcpy(colorname, colornames[1], sizeof(colorname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // DARKMAN_PATCH
|
||||||
|
|
||||||
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||||
void
|
void
|
||||||
xloadcols(void)
|
xloadcols(void)
|
||||||
|
|
@ -1021,6 +1046,8 @@ xloadcols(void)
|
||||||
static int loaded;
|
static int loaded;
|
||||||
Color *cp;
|
Color *cp;
|
||||||
|
|
||||||
|
darkmanThemeChoose();
|
||||||
|
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
|
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
|
||||||
XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
|
XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
|
||||||
|
|
@ -4045,9 +4072,12 @@ run:
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH
|
#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH || DARKMAN_PATCH
|
||||||
signal(SIGUSR1, sigusr1_reload);
|
signal(SIGUSR1, sigusr1_reload);
|
||||||
#endif // XRESOURCES_RELOAD_PATCH | BACKGROUND_IMAGE_RELOAD_PATCH
|
#endif // XRESOURCES_RELOAD_PATCH | BACKGROUND_IMAGE_RELOAD_PATCH | DARKMAN_PATCH
|
||||||
|
#if DARKMAN_PATCH
|
||||||
|
memcpy(colornames[0], colorname, sizeof(colorname));
|
||||||
|
#endif // DARKMAN_PATCH
|
||||||
#if XRESOURCES_PATCH
|
#if XRESOURCES_PATCH
|
||||||
if (!(xw.dpy = XOpenDisplay(NULL)))
|
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
die("Can't open display\n");
|
die("Can't open display\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue