diff options
| author | Markus Teich <markus.teich@stusta.mhn.de> | 2016-02-15 14:00:56 +0100 |
|---|---|---|
| committer | Markus Teich <markus.teich@stusta.mhn.de> | 2016-02-15 14:00:56 +0100 |
| commit | ec46680fe10ffc69007b0a8b29d9e69c72704053 (patch) | |
| tree | 1d47c6ca08324b6a3f70179b6e6a89776e9a4b0c | |
| parent | b02c4d452a7942d4be3c69e6f98dafd35a2e4e78 (diff) | |
revert using argv0 and minor fixup
- use hardcoded "slock" instead of argv[0]
- add "slock: " to fprintf calls, where it was missing
- revert `argc--, argv++` shifting
| -rw-r--r-- | slock.c | 15 |
1 files changed, 6 insertions, 9 deletions
| @@ -46,15 +46,14 @@ static Bool failure = False; | |||
| 46 | static Bool rr; | 46 | static Bool rr; |
| 47 | static int rrevbase; | 47 | static int rrevbase; |
| 48 | static int rrerrbase; | 48 | static int rrerrbase; |
| 49 | static char *argv0; | ||
| 50 | 49 | ||
| 51 | static void | 50 | static void |
| 52 | die(const char *errstr, ...) | 51 | die(const char *errstr, ...) |
| 53 | { | 52 | { |
| 54 | va_list ap; | 53 | va_list ap; |
| 55 | 54 | ||
| 55 | fputs("slock: ", stderr); | ||
| 56 | va_start(ap, errstr); | 56 | va_start(ap, errstr); |
| 57 | fprintf(stderr, "%s: ", argv0); | ||
| 58 | vfprintf(stderr, errstr, ap); | 57 | vfprintf(stderr, errstr, ap); |
| 59 | va_end(ap); | 58 | va_end(ap); |
| 60 | exit(1); | 59 | exit(1); |
| @@ -256,7 +255,7 @@ lockscreen(Display *dpy, int screen) | |||
| 256 | usleep(1000); | 255 | usleep(1000); |
| 257 | } | 256 | } |
| 258 | if (!len) { | 257 | if (!len) { |
| 259 | fprintf(stderr, "unable to grab mouse pointer for screen %d\n", screen); | 258 | fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n", screen); |
| 260 | } else { | 259 | } else { |
| 261 | for (len = 1000; len; len--) { | 260 | for (len = 1000; len; len--) { |
| 262 | if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) { | 261 | if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) { |
| @@ -266,7 +265,7 @@ lockscreen(Display *dpy, int screen) | |||
| 266 | } | 265 | } |
| 267 | usleep(1000); | 266 | usleep(1000); |
| 268 | } | 267 | } |
| 269 | fprintf(stderr, "unable to grab keyboard for screen %d\n", screen); | 268 | fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", screen); |
| 270 | } | 269 | } |
| 271 | /* grabbing one of the inputs failed */ | 270 | /* grabbing one of the inputs failed */ |
| 272 | running = 0; | 271 | running = 0; |
| @@ -283,8 +282,6 @@ main(int argc, char **argv) | |||
| 283 | Display *dpy; | 282 | Display *dpy; |
| 284 | int screen; | 283 | int screen; |
| 285 | 284 | ||
| 286 | argv0 = argv[0], argc--, argv++; | ||
| 287 | |||
| 288 | #ifdef __linux__ | 285 | #ifdef __linux__ |
| 289 | dontkillme(); | 286 | dontkillme(); |
| 290 | #endif | 287 | #endif |
| @@ -317,11 +314,11 @@ main(int argc, char **argv) | |||
| 317 | return 1; | 314 | return 1; |
| 318 | } | 315 | } |
| 319 | 316 | ||
| 320 | if (argc >= 1 && fork() == 0) { | 317 | if (argc >= 2 && fork() == 0) { |
| 321 | if (dpy) | 318 | if (dpy) |
| 322 | close(ConnectionNumber(dpy)); | 319 | close(ConnectionNumber(dpy)); |
| 323 | execvp(argv[0], argv); | 320 | execvp(argv[1], argv+1); |
| 324 | die("execvp %s failed: %s\n", argv[0], strerror(errno)); | 321 | die("execvp %s failed: %s\n", argv[1], strerror(errno)); |
| 325 | } | 322 | } |
| 326 | 323 | ||
| 327 | /* Everything is now blank. Now wait for the correct password. */ | 324 | /* Everything is now blank. Now wait for the correct password. */ |
