if lock tries exceeds 2. play alarm sound.

This commit is contained in:
Christopher Jeffrey 2014-07-16 14:54:53 -07:00
parent 1ba98464fd
commit 4e7c29374b

12
slock.c
View File

@ -24,6 +24,7 @@
#endif #endif
char *g_pw = NULL; char *g_pw = NULL;
int lock_tries = 0;
typedef struct { typedef struct {
int screen; int screen;
@ -68,7 +69,7 @@ getpw(void) { /* only run as root */
const char *rval; const char *rval;
struct passwd *pw; struct passwd *pw;
if (g_pw) if(g_pw)
return g_pw; return g_pw;
errno = 0; errno = 0;
@ -141,14 +142,19 @@ readpw(Display *dpy, const char *pws)
#ifdef HAVE_BSD_AUTH #ifdef HAVE_BSD_AUTH
running = !auth_userokay(getlogin(), NULL, "auth-xlock", passwd); running = !auth_userokay(getlogin(), NULL, "auth-xlock", passwd);
#else #else
if (g_pw) { if(g_pw) {
running = !!strcmp(passwd, g_pw); running = !!strcmp(passwd, g_pw);
} else { } else {
running = !!strcmp(crypt(passwd, pws), pws); running = !!strcmp(crypt(passwd, pws), pws);
} }
#endif #endif
if(running) if(running) {
XBell(dpy, 100); XBell(dpy, 100);
if(++lock_tries > 2) {
// http://soundbible.com/1819-Police.html
system("aplay /home/chjj/police.wav");
}
}
len = 0; len = 0;
break; break;
case XK_Escape: case XK_Escape: