mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
Add XRESOURCES_RELOAD_PATCH
This commit is contained in:
parent
ec513b230a
commit
540a923fb9
@ -34,19 +34,46 @@ resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if XRESOURCES_RELOAD_PATCH
|
||||||
|
void
|
||||||
|
config_init(Display *dpy)
|
||||||
|
{
|
||||||
|
#else
|
||||||
void
|
void
|
||||||
config_init(void)
|
config_init(void)
|
||||||
{
|
{
|
||||||
|
#endif // XRESOURCES_RELOAD_PATCH
|
||||||
char *resm;
|
char *resm;
|
||||||
XrmDatabase db;
|
XrmDatabase db;
|
||||||
ResourcePref *p;
|
ResourcePref *p;
|
||||||
|
|
||||||
XrmInitialize();
|
XrmInitialize();
|
||||||
|
#if XRESOURCES_RELOAD_PATCH
|
||||||
|
resm = XResourceManagerString(dpy);
|
||||||
|
#else
|
||||||
resm = XResourceManagerString(xw.dpy);
|
resm = XResourceManagerString(xw.dpy);
|
||||||
|
#endif // XRESOURCES_RELOAD_PATCH
|
||||||
if (!resm)
|
if (!resm)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
db = XrmGetStringDatabase(resm);
|
db = XrmGetStringDatabase(resm);
|
||||||
for (p = resources; p < resources + LEN(resources); p++)
|
for (p = resources; p < resources + LEN(resources); p++)
|
||||||
resource_load(db, p->name, p->type, p->dst);
|
resource_load(db, p->name, p->type, p->dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if XRESOURCES_RELOAD_PATCH
|
||||||
|
void reload_config(int sig){
|
||||||
|
/* Recreate a Display object to have up to date Xresources entries */
|
||||||
|
Display *dpy;
|
||||||
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
|
die("Can't open display\n");
|
||||||
|
|
||||||
|
config_init(dpy);
|
||||||
|
if (sig != -1) {
|
||||||
|
/* Called due to a SIGUSR1 */
|
||||||
|
xloadcols();
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
signal(SIGUSR1, reload_config);
|
||||||
|
}
|
||||||
|
#endif // XRESOURCES_RELOAD_PATCH
|
||||||
|
@ -14,4 +14,8 @@ typedef struct {
|
|||||||
} ResourcePref;
|
} ResourcePref;
|
||||||
|
|
||||||
int resource_load(XrmDatabase, char *, enum resource_type, void *);
|
int resource_load(XrmDatabase, char *, enum resource_type, void *);
|
||||||
void config_init(void);
|
#if XRESOURCES_RELOAD_PATCH
|
||||||
|
void config_init(Display *dpy);
|
||||||
|
#else
|
||||||
|
void config_init(void);
|
||||||
|
#endif // XRESOURCES_RELOAD_PATCH
|
||||||
|
@ -292,3 +292,9 @@
|
|||||||
* https://st.suckless.org/patches/xresources/
|
* https://st.suckless.org/patches/xresources/
|
||||||
*/
|
*/
|
||||||
#define XRESOURCES_PATCH 0
|
#define XRESOURCES_PATCH 0
|
||||||
|
|
||||||
|
/* This patch adds the ability to reload the Xresources config when a SIGUSR1 signal is received
|
||||||
|
e.g.: killall -USR1 st
|
||||||
|
Depends on the XRESOURCES_PATCH.
|
||||||
|
*/
|
||||||
|
#define XRESOURCES_RELOAD_PATCH 0
|
||||||
|
6
x.c
6
x.c
@ -2576,12 +2576,14 @@ run:
|
|||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
#if XRESOURCES_PATCH
|
#if XRESOURCES_RELOAD_PATCH
|
||||||
|
reload_config(-1);
|
||||||
|
#elif XRESOURCES_PATCH
|
||||||
if (!(xw.dpy = XOpenDisplay(NULL)))
|
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
die("Can't open display\n");
|
die("Can't open display\n");
|
||||||
|
|
||||||
config_init();
|
config_init();
|
||||||
#endif // XRESOURCES_PATCH
|
#endif // XRESOURCES_RELOAD_PATCH
|
||||||
cols = MAX(cols, 1);
|
cols = MAX(cols, 1);
|
||||||
rows = MAX(rows, 1);
|
rows = MAX(rows, 1);
|
||||||
tnew(cols, rows);
|
tnew(cols, rows);
|
||||||
|
Loading…
Reference in New Issue
Block a user