summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Lehner <cel@celehner.com>2016-01-09 14:18:53 -0500
committerChristoph Lohmann <20h@r-36.net>2016-01-09 21:14:30 +0100
commit0ac6bf5a973159117c2457bf27e5c7b554f112ca (patch)
tree38d99bbdb03a5051e64659595dd17abd5d8a23b4
parent3d81a0f0b7ffaccb5c4b978ad06d130b2a57b645 (diff)
downloadsurf-0ac6bf5a973159117c2457bf27e5c7b554f112ca.tar.gz
surf-0ac6bf5a973159117c2457bf27e5c7b554f112ca.tar.bz2
surf-0ac6bf5a973159117c2457bf27e5c7b554f112ca.zip
Reload on SIGHUP
This patch makes surf reload its pages when it receives a SIGHUP signal. This makes it easier for shell scripts to trigger surf to reload. I'm aware of using xdotool to trigger ctrl+r keypresses for reloading [1] but I wasn't able to get that to work in a general way. I'm sending this here in case surf maintainers and users would like to include this in core - if not I will submit it to the wiki. Regards, Charles [1] http://surf.suckless.org/files/autorefresh Signed-off-by: Christoph Lohmann <20h@r-36.net>
-rw-r--r--surf.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/surf.c b/surf.c
index 70cd2c7..a672d2d 100644
--- a/surf.c
+++ b/surf.c
@@ -197,6 +197,7 @@ static void scroll(GtkAdjustment *a, const Arg *arg);
static void setatom(Client *c, int a, const char *v);
static void setup(void);
static void sigchld(int unused);
+static void sighup(int unused);
static void source(Client *c, const Arg *arg);
static void spawn(Client *c, const Arg *arg);
static void stop(Client *c, const Arg *arg);
@@ -1300,6 +1301,8 @@ setup(void)
/* clean up any zombies immediately */
sigchld(0);
+ if (signal(SIGHUP, sighup) == SIG_ERR)
+ die("Can't install SIGHUP handler");
gtk_init(NULL, NULL);
dpy = GDK_DISPLAY();
@@ -1395,6 +1398,16 @@ sigchld(int unused)
}
void
+sighup(int unused)
+{
+ Arg a = { .b = FALSE };
+ Client *c;
+
+ for (c = clients; c; c = c->next)
+ reload(c, &a);
+}
+
+void
source(Client *c, const Arg *arg)
{
Arg a = { .b = FALSE };