diff options
-rw-r--r-- | slock.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -1,3 +1,4 @@ | |||
1 | |||
1 | /* See LICENSE file for license details. */ | 2 | /* See LICENSE file for license details. */ |
2 | #define _XOPEN_SOURCE 500 | 3 | #define _XOPEN_SOURCE 500 |
3 | #if HAVE_SHADOW_H | 4 | #if HAVE_SHADOW_H |
@@ -211,9 +212,9 @@ lockscreen(Display *dpy, int screen) { | |||
211 | break; | 212 | break; |
212 | usleep(1000); | 213 | usleep(1000); |
213 | } | 214 | } |
214 | running = (len > 0); | ||
215 | } | 215 | } |
216 | 216 | ||
217 | running &= (len > 0); | ||
217 | if(!running) { | 218 | if(!running) { |
218 | unlockscreen(dpy, lock); | 219 | unlockscreen(dpy, lock); |
219 | lock = NULL; | 220 | lock = NULL; |
@@ -257,10 +258,20 @@ main(int argc, char **argv) { | |||
257 | locks = malloc(sizeof(Lock *) * nscreens); | 258 | locks = malloc(sizeof(Lock *) * nscreens); |
258 | if(locks == NULL) | 259 | if(locks == NULL) |
259 | die("slock: malloc: %s", strerror(errno)); | 260 | die("slock: malloc: %s", strerror(errno)); |
260 | for(screen = 0; screen < nscreens; screen++) | 261 | int nlocks = 0; |
261 | locks[screen] = lockscreen(dpy, screen); | 262 | for(screen = 0; screen < nscreens; screen++) { |
263 | if ( (locks[screen] = lockscreen(dpy, screen)) != NULL) | ||
264 | nlocks++; | ||
265 | } | ||
262 | XSync(dpy, False); | 266 | XSync(dpy, False); |
263 | 267 | ||
268 | /* Did we actually manage to lock something? */ | ||
269 | if (nlocks == 0) { // nothing to protect | ||
270 | free(locks); | ||
271 | XCloseDisplay(dpy); | ||
272 | return 1; | ||
273 | } | ||
274 | |||
264 | /* Everything is now blank. Now wait for the correct password. */ | 275 | /* Everything is now blank. Now wait for the correct password. */ |
265 | #ifdef HAVE_BSD_AUTH | 276 | #ifdef HAVE_BSD_AUTH |
266 | readpw(dpy); | 277 | readpw(dpy); |