st

fork of suckless's simple terminal
Index Commits Files Refs README LICENSE
commit ea994260ee5d13ca1c01476a560ebe7bc24b5fe8
parent 5016961ef88fa9b77fcb98d241539cf5e419cd7e
Author: mjkloeckner <martin.cachari@gmail.com>
Date:   Sat,  7 Jan 2023 20:14:57 -0300

add support for colorscheme switch  if SIGUSR(1-2) received

now if the process id of st receives a SIGUSR1 the colorscheme will be
set to dark, if it receives a SIGUSR2 st will change to a light scheme

the default colorscheme of st will be set depending of an existing file
located in $HOME/.config/scheme, if a file called 'light' exists on that
directory st will be started with a light scheme, if a file called
'dark' exist st will start with a dark scheme

Diffstat:
Mconfig.def.h | 35++++++++++++++++++++++++++++-------
Apatches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtags | 24++++++++++++++++--------
Mx.c | 26++++++++++++++++++++++++++
4 files changed, 148 insertions(+), 15 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -135,8 +135,10 @@ static const ColorScheme schemes[] = {
         "#83a598", /* blue    */
         "#d3869b", /* magenta */
         "#8ec07c", /* cyan    */
-        "#ebdbb2", /* white   */
-        [256]="#a89984", "#040505"}, 15, 0, 256, 257},
+        /* "#ebdbb2", /1* white   *1/ */
+        "#f9f4e8", /* white   */
+        /* [256]="#a89984", "#040505"}, 15, 0, 256, 257}, */
+        [256]="#e5e0da", "#040505"}, 15, 0, 256, 257},
 
     // Alacritty (dark)
     {{"#1d1f21", "#cc6666", "#b5bd68", "#f0c674",
@@ -181,15 +183,25 @@ static const ColorScheme schemes[] = {
       [256]="#ebdbb2", "#555555"}, 15, 0, 256, 257},
 
     // Gruvbox light
-    {{"#fbf1c7", "#cc241d", "#98971a", "#d79921",
+    /* {{"#fbf1c7", "#cc241d", "#98971a", "#d79921", */
+    /* {{"#f9ecb2", "#cc241d", "#98971a", "#d79921", */
+    {{"#f7efcb", "#cc241d", "#98971a", "#d79921",
       "#458588", "#b16286", "#689d6a", "#7c6f64",
       "#928374", "#9d0006", "#79740e", "#b57614",
       "#076678", "#8f3f71", "#427b58", "#3c3836",
       [256]="#3c3836", "#555555"}, 15, 0, 256, 257},
+
+    // Gruvbox light with One Half white bg
+    {{"#fbf9f9", "#cc241d", "#98971a", "#d79921",
+      "#458588", "#b16286", "#689d6a", "#0f0e0d",
+      "#928374", "#9d0006", "#79740e", "#b57614",
+      /* "#076678", "#8f3f71", "#427b58", "#3f3b39", */
+      "#076678", "#8f3f71", "#427b58", "#000000",
+      [256]="#3c3836", "#555555"}, 7, 0, 256, 257},
 };
 
 static const char * const * colorname;
-int colorscheme = 0;
+int colorscheme = 8;
 
 /*
  * Default colors (colorname index)
@@ -263,9 +275,17 @@ static MouseShortcut mshortcuts[] = {
 #define TERMMOD (ControlMask|ShiftMask)
 
 static unsigned char scheme = 0;
-static void togglescheme() {
-    Arg s = {.i = (scheme = (scheme ? 0 : 7))};
-    selectscheme(&s);
+void togglescheme(void) {
+    scheme = (scheme ? 0 : 8);
+    selectscheme(&(Arg){.i = scheme});
+}
+
+void setdarkscheme(void) {
+    selectscheme(&(Arg){.i = 0});
+}
+
+void setlightscheme(void) {
+    selectscheme(&(Arg){.i = 8});
 }
 
 static Shortcut shortcuts[] = {
@@ -292,6 +312,7 @@ static Shortcut shortcuts[] = {
     { MODKEY,               XK_8,           selectscheme,   {.i =  7} },
     { MODKEY,               XK_9,           selectscheme,   {.i =  8} },
     { MODKEY,               XK_0,           togglescheme,   {.i = -1} },
+    { MODKEY,               XK_F1,          togglescheme,   {.i = -1} },
     { ShiftMask,            XK_Page_Up,     kscrollup,      {.i = -1} },
     { ShiftMask,            XK_Page_Down,   kscrolldown,    {.i = -1} },
 };
diff --git a/patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff b/patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff
@@ -0,0 +1,78 @@
+From 580e3f386e9215707100e9ba44797701943fd927 Mon Sep 17 00:00:00 2001
+From: asparagii <michele.lambertucci1@gmail.com>
+Date: Thu, 27 Jan 2022 15:49:27 +0100
+Subject: [PATCH] st-scrollback-mouse-altscreen
+
+---
+ config.def.h | 4 ++--
+ st.c         | 5 +++++
+ st.h         | 1 +
+ x.c          | 2 ++
+ 4 files changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index c217315..c223706 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -176,8 +176,8 @@ static uint forcemousemod = ShiftMask;
+  */
+ static MouseShortcut mshortcuts[] = {
+     /* mask                 button   function        argument       release */
+-    { ShiftMask,            Button4, kscrollup,      {.i = 1} },
+-    { ShiftMask,            Button5, kscrolldown,    {.i = 1} },
++    { XK_ANY_MOD,           Button4, kscrollup,      {.i = 1},        0, /* !alt */ -1 },
++    { XK_ANY_MOD,           Button5, kscrolldown,    {.i = 1},        0, /* !alt */ -1 },
+     { XK_ANY_MOD,           Button2, selpaste,       {.i = 0},      1 },
+     { ShiftMask,            Button4, ttysend,        {.s = "\033[5;2~"} },
+     { XK_ANY_MOD,           Button4, ttysend,        {.s = "\031"} },
+diff --git a/st.c b/st.c
+index f3af82b..876a6bf 100644
+--- a/st.c
++++ b/st.c
+@@ -1060,6 +1060,11 @@ tnew(int col, int row)
+     treset();
+ }
+ 
++int tisaltscr(void)
++{
++    return IS_SET(MODE_ALTSCREEN);
++}
++
+ void
+ tswapscreen(void)
+ {
+diff --git a/st.h b/st.h
+index da36b34..e95c6f8 100644
+--- a/st.h
++++ b/st.h
+@@ -89,6 +89,7 @@ void sendbreak(const Arg *);
+ void toggleprinter(const Arg *);
+ 
+ int tattrset(int);
++int tisaltscr(void);
+ void tnew(int, int);
+ void tresize(int, int);
+ void tsetdirtattr(int);
+diff --git a/x.c b/x.c
+index cd96575..9274556 100644
+--- a/x.c
++++ b/x.c
+@@ -34,6 +34,7 @@ typedef struct {
+     void (*func)(const Arg *);
+     const Arg arg;
+     uint  release;
++    int  altscrn;  /* 0: don't care, -1: not alt screen, 1: alt screen */
+ } MouseShortcut;
+ 
+ typedef struct {
+@@ -455,6 +456,7 @@ mouseaction(XEvent *e, uint release)
+     for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
+         if (ms->release == release &&
+             ms->button == e->xbutton.button &&
++            (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
+             (match(ms->mod, state) ||  /* exact or forced */
+              match(ms->mod, state & ~forcemousemod))) {
+             ms->func(&(ms->arg));
+-- 
+2.34.1
+
diff --git a/tags b/tags
@@ -6,6 +6,7 @@ $(OBJ)	Makefile	/^$(OBJ): config.h config.mk$/;"	t
 -1047,6 +1047,11    patches/st-universcroll-0.8.4.diff    /^@@ -1047,6 +1047,11 @@ tnew(int col, int row)$/;"    h    modifiedFile:a/st.c
 -105,6 +105,7    patches/st-alpha-20220206-0.8.5.diff    /^@@ -105,6 +105,7 @@ typedef struct {$/;"    h    modifiedFile:a/x.c
 -1053,14 +1087,42    patches/st-scrollback-ringbuffer-0.8.5.diff    /^@@ -1053,14 +1087,42 @@ tnew(int col, int row)$/;"    h    modifiedFile:a/st.c
+-1060,6 +1060,11    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^@@ -1060,6 +1060,11 @@ tnew(int col, int row)$/;"    h    modifiedFile:a/st.c
 -1061,13 +1071,53    patches/st-scrollback-20210507-4536f46.diff    /^@@ -1061,13 +1071,53 @@ tswapscreen(void)$/;"    h    modifiedFile:a/st.c
 -1069,15 +1131,29    patches/st-scrollback-ringbuffer-0.8.5.diff    /^@@ -1069,15 +1131,29 @@ tscrolldown(int orig, int n)$/;"    h    modifiedFile:a/st.c
 -1069,17 +1201,22    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -1069,17 +1201,22 @@ kscrolldown(const Arg* a)$/;"    h    modifiedFile:a/st.c
@@ -47,6 +48,7 @@ $(OBJ)	Makefile	/^$(OBJ): config.h config.mk$/;"	t
 -1735,11 +1797,11    patches/st-scrollback-20210507-4536f46.diff    /^@@ -1735,11 +1797,11 @@ csihandle(void)$/;"    h    modifiedFile:a/st.c
 -1757,20 +1917,30    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -1757,20 +1917,30 @@ csihandle(void)$/;"    h    modifiedFile:a/st.c
 -176,6 +176,8    patches/st-scrollback-mouse-20220127-2c5edf2.diff    /^@@ -176,6 +176,8 @@ static uint forcemousemod = ShiftMask;$/;"    h    modifiedFile:a/config.def.h
+-176,8 +176,8    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^@@ -176,8 +176,8 @@ static uint forcemousemod = ShiftMask;$/;"    h    modifiedFile:a/config.def.h
 -1778,24 +1948,24    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -1778,24 +1948,24 @@ csihandle(void)$/;"    h    modifiedFile:a/st.c
 -179,26 +200,37    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -179,26 +200,37 @@ static void tprinter(char *, size_t);$/;"    h    modifiedFile:a/st.c
 -1809,9 +1979,11    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -1809,9 +1979,11 @@ csihandle(void)$/;"    h    modifiedFile:a/st.c
@@ -92,6 +94,7 @@ $(OBJ)	Makefile	/^$(OBJ): config.h config.mk$/;"	t
 -2709,9 +3057,8    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -2709,9 +3057,8 @@ draw(void)$/;"    h    modifiedFile:a/st.c
 -331,7 +332,7    patches/st-anysize-20220718-baa9357.diff    /^@@ -331,7 +332,7 @@ ttysend(const Arg *arg)$/;"    h    modifiedFile:a/x.c
 -339,7 +340,7    patches/st-anysize-20220718-baa9357.diff    /^@@ -339,7 +340,7 @@ evcol(XEvent *e)$/;"    h    modifiedFile:a/x.c
+-34,6 +34,7    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^@@ -34,6 +34,7 @@ typedef struct {$/;"    h    modifiedFile:a/x.c
 -34,6 +34,7    patches/st-universcroll-0.8.4.diff    /^@@ -34,6 +34,7 @@ typedef struct {$/;"    h    modifiedFile:a/x.c
 -35,6 +35,7    patches/st-scrollback-20210507-4536f46.diff    /^@@ -35,6 +35,7 @@$/;"    h    modifiedFile:a/st.c
 -36,6 +36,7    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -36,6 +36,7 @@$/;"    h    modifiedFile:a/st.c
@@ -102,6 +105,7 @@ $(OBJ)	Makefile	/^$(OBJ): config.h config.mk$/;"	t
 -43,6 +43,10    patches/st-scrollback-ringbuffer-0.8.5.diff    /^@@ -43,6 +43,10 @@$/;"    h    modifiedFile:a/st.c
 -43,9 +44,22    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -43,9 +44,22 @@$/;"    h    modifiedFile:a/st.c
 -446,6 +447,7    patches/st-universcroll-0.8.4.diff    /^@@ -446,6 +447,7 @@ mouseaction(XEvent *e, uint release)$/;"    h    modifiedFile:a/x.c
+-455,6 +456,7    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^@@ -455,6 +456,7 @@ mouseaction(XEvent *e, uint release)$/;"    h    modifiedFile:a/x.c
 -462,10 +526,11    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -462,10 +526,11 @@ selextend(int col, int row, int type, int done)$/;"    h    modifiedFile:a/st.c
 -492,36 +557,43    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -492,36 +557,43 @@ selnormalize(void)$/;"    h    modifiedFile:a/st.c
 -528,7 +535,7    patches/st-scrollback-20210507-4536f46.diff    /^@@ -528,7 +535,7 @@ selsnap(int *x, int *y, int direction)$/;"    h    modifiedFile:a/st.c
@@ -131,6 +135,7 @@ $(OBJ)	Makefile	/^$(OBJ): config.h config.mk$/;"	t
 -851,10 +919,8    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -851,10 +919,8 @@ void$/;"    h    modifiedFile:a/st.c
 -869,8 +873,8    patches/st-anysize-20220718-baa9357.diff    /^@@ -869,8 +873,8 @@ xhints(void)$/;"    h    modifiedFile:a/x.c
 -87,6 +87,7    patches/st-universcroll-0.8.4.diff    /^@@ -87,6 +87,7 @@ void sendbreak(const Arg *);$/;"    h    modifiedFile:a/st.h
+-89,6 +89,7    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^@@ -89,6 +89,7 @@ void sendbreak(const Arg *);$/;"    h    modifiedFile:a/st.h
 -90,6 +90,8    patches/st-colorschemes-0.8.5.diff    /^@@ -90,6 +90,8 @@ int tattrset(int);$/;"    h    modifiedFile:a/st.h
 -90,6 +92,7    patches/st-scrollback-reflow-0.8.5.diff    /^@@ -90,6 +92,7 @@ void toggleprinter(const Arg *);$/;"    h    modifiedFile:a/st.h
 -93,46 +93,87    patches/st-colorschemes-0.8.5.diff    /^@@ -93,46 +93,87 @@ char *termname = "st-256color";$/;"    h    modifiedFile:a/config.def.h
@@ -239,17 +244,20 @@ a/config.def.h	patches/st-colorschemes-0.8.5.diff	/^--- a\/config.def.h$/;"	m
 a/config.def.h    patches/st-gruvbox-dark-0.8.5.diff    /^--- a\/config.def.h$/;"    m
 a/config.def.h    patches/st-scrollback-20210507-4536f46.diff    /^--- a\/config.def.h$/;"    m
 a/config.def.h    patches/st-scrollback-mouse-20220127-2c5edf2.diff    /^--- a\/config.def.h$/;"    m
+a/config.def.h    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^--- a\/config.def.h$/;"    m
 a/config.def.h    patches/st-scrollback-ringbuffer-0.8.5.diff    /^--- a\/config.def.h$/;"    m
 a/config.def.h    patches/st-universcroll-0.8.4.diff    /^--- a\/config.def.h$/;"    m
 a/config.mk    patches/st-alpha-20220206-0.8.5.diff    /^--- a\/config.mk$/;"    m
 a/st.c    patches/st-colorschemes-0.8.5.diff    /^--- a\/st.c$/;"    m
 a/st.c    patches/st-scrollback-20210507-4536f46.diff    /^--- a\/st.c$/;"    m
+a/st.c    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^--- a\/st.c$/;"    m
 a/st.c    patches/st-scrollback-reflow-0.8.5.diff    /^--- a\/st.c$/;"    m
 a/st.c    patches/st-scrollback-ringbuffer-0.8.5.diff    /^--- a\/st.c$/;"    m
 a/st.c    patches/st-universcroll-0.8.4.diff    /^--- a\/st.c$/;"    m
 a/st.h    patches/st-alpha-20220206-0.8.5.diff    /^--- a\/st.h$/;"    m
 a/st.h    patches/st-colorschemes-0.8.5.diff    /^--- a\/st.h$/;"    m
 a/st.h    patches/st-scrollback-20210507-4536f46.diff    /^--- a\/st.h$/;"    m
+a/st.h    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^--- a\/st.h$/;"    m
 a/st.h    patches/st-scrollback-reflow-0.8.5.diff    /^--- a\/st.h$/;"    m
 a/st.h    patches/st-scrollback-ringbuffer-0.8.5.diff    /^--- a\/st.h$/;"    m
 a/st.h    patches/st-universcroll-0.8.4.diff    /^--- a\/st.h$/;"    m
@@ -257,6 +265,7 @@ a/x.c	patches/st-alpha-20220206-0.8.5.diff	/^--- a\/x.c$/;"	m
 a/x.c    patches/st-anysize-20220718-baa9357.diff    /^--- a\/x.c$/;"    m
 a/x.c    patches/st-blinking_cursor-20211116-2f6e597.diff    /^--- a\/x.c$/;"    m
 a/x.c    patches/st-colorschemes-0.8.5.diff    /^--- a\/x.c$/;"    m
+a/x.c    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    /^--- a\/x.c$/;"    m
 a/x.c    patches/st-scrollback-ringbuffer-0.8.5.diff    /^--- a\/x.c$/;"    m
 a/x.c    patches/st-universcroll-0.8.4.diff    /^--- a\/x.c$/;"    m
 all    Makefile    /^all: options st$/;"    t
@@ -299,9 +308,9 @@ colorscheme	config.def.h	/^int colorscheme = 0;$/;"	v	typeref:typename:int
 colorscheme    config.h    /^int colorscheme = 0;$/;"    v    typeref:typename:int
 cols    config.def.h    /^static unsigned int cols = 80;$/;"    v    typeref:typename:unsigned int
 cols    config.h    /^static unsigned int cols = 80;$/;"    v    typeref:typename:unsigned int
-config.def.h    config.def.h    1;"    F    epoch:1667356965
+config.def.h    config.def.h    1;"    F    epoch:1667403455
 config.h    Makefile    /^config.h:$/;"    t
-config.h    config.h    1;"    F    epoch:1667356753
+config.h    config.h    1;"    F    epoch:1667403739
 config.mk    config.mk    1;"    F    epoch:1667356258
 cresize    x.c    /^cresize(int width, int height)$/;"    f    typeref:typename:void
 cs    config.def.h    /^    unsigned int cs;               \/* cursor *\/$/;"    m    struct:__anon9258968e0108    typeref:typename:unsigned int
@@ -394,10 +403,9 @@ rows	config.def.h	/^static unsigned int rows = 24;$/;"	v	typeref:typename:unsign
 rows    config.h    /^static unsigned int rows = 24;$/;"    v    typeref:typename:unsigned int
 run    x.c    /^run(void)$/;"    f    typeref:typename:void
 s    st.h    /^    const char *s;$/;"    m    union:__anon7c9e12e2020a    typeref:typename:const char *
-scheme    config.def.h    /^static void scheme = 0;$/;"    v    typeref:typename:void
-scheme    config.h    /^static unsigned char scheme = 0;$/;"    v    typeref:typename:unsigned char
 schemes    config.def.h    /^static const ColorScheme schemes[] = {$/;"    v    typeref:typename:const ColorScheme[]
 schemes    config.h    /^static const ColorScheme schemes[] = {$/;"    v    typeref:typename:const ColorScheme[]
+schemesighandler    x.c    /^void schemesighandler(int signum) {$/;"    f    typeref:typename:void
 scroll    config.def.h    /^char *scroll = NULL;$/;"    v    typeref:typename:char *
 scroll    config.h    /^char *scroll = NULL;$/;"    v    typeref:typename:char *
 selclear    st.c    /^selclear(void)$/;"    f    typeref:typename:void
@@ -434,11 +442,12 @@ st-colorschemes-0.8.5.diff	patches/st-colorschemes-0.8.5.diff	1;"	F	epoch:166735
 st-gruvbox-dark-0.8.5.diff    patches/st-gruvbox-dark-0.8.5.diff    1;"    F    epoch:1667356258
 st-scrollback-20210507-4536f46.diff    patches/st-scrollback-20210507-4536f46.diff    1;"    F    epoch:1667356258
 st-scrollback-mouse-20220127-2c5edf2.diff    patches/st-scrollback-mouse-20220127-2c5edf2.diff    1;"    F    epoch:1667356258
+st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    patches/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff    1;"    F    epoch:1667357783
 st-scrollback-reflow-0.8.5.diff    patches/st-scrollback-reflow-0.8.5.diff    1;"    F    epoch:1667356258
 st-scrollback-ringbuffer-0.8.5.diff    patches/st-scrollback-ringbuffer-0.8.5.diff    1;"    F    epoch:1667356258
 st-universcroll-0.8.4.diff    patches/st-universcroll-0.8.4.diff    1;"    F    epoch:1667356258
 st.1    st.1    1;"    F    epoch:1667356258
-st.c    st.c    1;"    F    epoch:1667356329
+st.c    st.c    1;"    F    epoch:1667403488
 st.h    st.h    1;"    F    epoch:1667356329
 st.o    Makefile    /^st.o: config.h st.h win.h$/;"    t
 stcursor    config.def.h    /^static Rune stcursor = 0x2603; \/* snowman ("☃") *\/$/;"    v    typeref:typename:Rune
@@ -477,8 +486,7 @@ tmoveto	st.c	/^tmoveto(int x, int y)$/;"	f	typeref:typename:void
 tnew    st.c    /^tnew(int col, int row)$/;"    f    typeref:typename:void
 tnewline    st.c    /^tnewline(int first_col)$/;"    f    typeref:typename:void
 toggleprinter    st.c    /^toggleprinter(const Arg *arg)$/;"    f    typeref:typename:void
-togglescheme    config.def.h    /^static void togglescheme() {$/;"    f    typeref:typename:void
-togglescheme    config.h    /^static unsigned char togglescheme() {$/;"    f    typeref:typename:unsigned char
+togglescheme    x.c    /^void togglescheme(void) {$/;"    f    typeref:typename:void
 tprinter    st.c    /^tprinter(char *s, size_t len)$/;"    f    typeref:typename:void
 tputc    st.c    /^tputc(Rune u)$/;"    f    typeref:typename:void
 tputtab    st.c    /^tputtab(int n)$/;"    f    typeref:typename:void
@@ -531,7 +539,7 @@ win.h	win.h	1;"	F	epoch:1667356258
 win_mode    win.h    /^enum win_mode {$/;"    g
 worddelimiters    config.def.h    /^wchar_t *worddelimiters = L" ";$/;"    v    typeref:typename:wchar_t *
 worddelimiters    config.h    /^wchar_t *worddelimiters = L" ";$/;"    v    typeref:typename:wchar_t *
-x.c    x.c    1;"    F    epoch:1667356911
+x.c    x.c    1;"    F    epoch:1667403735
 x.o    Makefile    /^x.o: arg.h config.h st.h win.h$/;"    t
 xbell    x.c    /^xbell(void)$/;"    f    typeref:typename:void
 xclear    x.c    /^xclear(int x1, int y1, int x2, int y2)$/;"    f    typeref:typename:void
diff --git a/x.c b/x.c
@@ -62,6 +62,10 @@ static void zoomreset(const Arg *);
 static void ttysend(const Arg *);
 static void nextscheme(const Arg *);
 static void selectscheme(const Arg *);
+void togglescheme(void);
+void setdarkscheme(void);
+void setlightscheme(void);
+void schemesighandler(int signum);
 
 /* config.h for applying patches and the configuration. */
 #include "config.h"
@@ -1981,6 +1985,12 @@ run(void)
     ttyfd = ttynew(opt_line, shell, opt_io, opt_cmd);
     cresize(w, h);
 
+#include <unistd.h>
+    if(!access("/home/mk/.config/scheme/light", F_OK))
+        setlightscheme();
+    else if(!access("/home/mk/.config/scheme/dark", F_OK))
+        setdarkscheme();
+
     for (timeout = -1, drawing = 0, lastblink = (struct timespec){0};;) {
         FD_ZERO(&rfd);
         FD_SET(ttyfd, &rfd);
@@ -2113,6 +2123,14 @@ updatescheme(void)
     redraw();
 }
 
+void schemesighandler(int signum) {
+    if (signum == SIGUSR1)
+        setdarkscheme();
+
+    if (signum == SIGUSR2)
+        setlightscheme();
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -2182,6 +2200,14 @@ run:
 
     setlocale(LC_CTYPE, "");
     XSetLocaleModifiers("");
+
+    struct sigaction sa;
+    sa.sa_handler = schemesighandler;
+    sa.sa_flags = SA_RESTART;
+    sigemptyset(&sa.sa_mask);
+    sigaction(SIGUSR1, &sa, 0);
+    sigaction(SIGUSR2, &sa, 0);
+
     cols = MAX(cols, 1);
     rows = MAX(rows, 1);
     tnew(cols, rows);