Hi,
I got sick of the XBell in slock, so I added getopt support and a silent
option (default = False), patched against the mercurial tip.
I read the manifest and some of the source code; some of the projects
use getopt, others push config elsewhere. Am not sure which should apply
to slock.
Patrick
diff -urN slock-1.0/slock.c slock-1.0-getopt//slock.c
--- slock-1.0/slock.c 2009-11-26 20:53:26.000000000 +0800
+++ slock-1.0-getopt//slock.c 2010-09-18 12:34:56.761712744 +0800
@@ -74,9 +74,9 @@
static void
#ifdef HAVE_BSD_AUTH
-read_password(Display *dpy)
+read_password(Display *dpy, Bool silent)
#else
-read_password(Display *dpy, const char *pws)
+read_password(Display *dpy, const char *pws, Bool silent)
#endif
{
char buf[32], passwd[256];
@@ -117,7 +117,7 @@
#else
running = strcmp(crypt(passwd, pws), pws);
#endif
- if (running != 0)
+ if (running != 0 && silent == False)
XBell(dpy, 100);
len = 0;
break;
@@ -209,7 +209,13 @@
static void
usage(void) {
- fprintf(stderr, "usage: %s -v", __progname);
+ fprintf(stderr, "slock-%s, © 2006-2008 Anselm R Garbe\n"
+ "usage: %s [-h|-s|-v]\n"
+ "\t-h show this message\n"
+ "\t-s silent (don't ring bell on password failure)\n"
+ "\t-v show this message\n"
+ , VERSION, __progname
+ );
exit(EXIT_FAILURE);
}
@@ -219,14 +225,19 @@
const char *pws;
#endif
Display *dpy;
- int nscreens, screen;
+ int nscreens, screen, opt;
+ Bool silent = False;
struct st_lock **locks;
- if((argc == 2) && !strcmp("-v", argv[1]))
- die("slock-%s, © 2006-2008 Anselm R Garbe", VERSION);
- else if(argc != 1)
- usage();
+ while ( (opt = getopt(argc, argv, "hsv")) != -1) {
+ switch (opt) {
+ case 's':
+ silent = True; break;
+ default:
+ usage();
+ }
+ }
#ifndef HAVE_BSD_AUTH
pws = get_password();
@@ -248,9 +259,9 @@
/* Everything is now blank. Now wait for the correct password. */
#ifdef HAVE_BSD_AUTH
- read_password(dpy);
+ read_password(dpy, silent);
#else
- read_password(dpy, pws);
+ read_password(dpy, pws, silent);
#endif
/* Password ok, unlock everything and quit. */