[hackers] [slock] add option to run command after screen is locked || Markus Teich

From: <git_AT_suckless.org>
Date: Tue, 29 Dec 2015 20:34:55 +0100 (CET)

commit e867c38123175d6f050e051ee6b00f4737a9712a
Author: Markus Teich <markus.teich_AT_stusta.mhn.de>
AuthorDate: Sat Dec 26 13:13:25 2015 +0100
Commit: Markus Teich <markus.teich_AT_stusta.mhn.de>
CommitDate: Sat Dec 26 19:27:01 2015 +0100

    add option to run command after screen is locked

diff --git a/slock.c b/slock.c
index 6be8f22..ddf1074 100644
--- a/slock.c
+++ b/slock.c
_AT_@ -289,7 +289,7 @@ lockscreen(Display *dpy, int screen)
 static void
 usage(void)
 {
- fprintf(stderr, "usage: slock [-v]\n");
+ fprintf(stderr, "usage: slock [-v|POST_LOCK_CMD]\n");
         exit(1);
 }
 
_AT_@ -303,7 +303,8 @@ main(int argc, char **argv) {
 
         if ((argc == 2) && !strcmp("-v", argv[1]))
                 die("slock-%s, © 2006-2015 slock engineers\n", VERSION);
- else if (argc != 1)
+
+ if ((argc == 2) && !strcmp("-h", argv[1]))
                 usage();
 
 #ifdef __linux__
_AT_@ -339,6 +340,13 @@ main(int argc, char **argv) {
                 return 1;
         }
 
+ if (argc >= 2 && fork() == 0) {
+ if (dpy)
+ close(ConnectionNumber(dpy));
+ execvp(argv[1], argv+1);
+ die("slock: execvp %s failed: %s\n", argv[1], strerror(errno));
+ }
+
         /* Everything is now blank. Now wait for the correct password. */
 #ifdef HAVE_BSD_AUTH
         readpw(dpy);
Received on Tue Dec 29 2015 - 20:34:55 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 29 2015 - 20:36:13 CET