aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2015-12-26 13:13:25 +0100
committerMarkus Teich <markus.teich@stusta.mhn.de>2015-12-26 19:27:01 +0100
commite867c38123175d6f050e051ee6b00f4737a9712a (patch)
treec5b69e98bf6f0258420228eac0d0f1cb25a4d57a
parentb95ee111c7625375716e848ec81af2f57ca35b02 (diff)
add option to run command after screen is locked
-rw-r--r--slock.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/slock.c b/slock.c
index 6be8f22..ddf1074 100644
--- a/slock.c
+++ b/slock.c
@@ -289,7 +289,7 @@ lockscreen(Display *dpy, int screen)
289static void 289static void
290usage(void) 290usage(void)
291{ 291{
292 fprintf(stderr, "usage: slock [-v]\n"); 292 fprintf(stderr, "usage: slock [-v|POST_LOCK_CMD]\n");
293 exit(1); 293 exit(1);
294} 294}
295 295
@@ -303,7 +303,8 @@ main(int argc, char **argv) {
303 303
304 if ((argc == 2) && !strcmp("-v", argv[1])) 304 if ((argc == 2) && !strcmp("-v", argv[1]))
305 die("slock-%s, © 2006-2015 slock engineers\n", VERSION); 305 die("slock-%s, © 2006-2015 slock engineers\n", VERSION);
306 else if (argc != 1) 306
307 if ((argc == 2) && !strcmp("-h", argv[1]))
307 usage(); 308 usage();
308 309
309#ifdef __linux__ 310#ifdef __linux__
@@ -339,6 +340,13 @@ main(int argc, char **argv) {
339 return 1; 340 return 1;
340 } 341 }
341 342
343 if (argc >= 2 && fork() == 0) {
344 if (dpy)
345 close(ConnectionNumber(dpy));
346 execvp(argv[1], argv+1);
347 die("slock: execvp %s failed: %s\n", argv[1], strerror(errno));
348 }
349
342 /* Everything is now blank. Now wait for the correct password. */ 350 /* Everything is now blank. Now wait for the correct password. */
343#ifdef HAVE_BSD_AUTH 351#ifdef HAVE_BSD_AUTH
344 readpw(dpy); 352 readpw(dpy);