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
This commit is contained in:
parent
b02c4d452a
commit
ec46680fe1
15
slock.c
15
slock.c
|
@ -46,15 +46,14 @@ static Bool failure = False;
|
||||||
static Bool rr;
|
static Bool rr;
|
||||||
static int rrevbase;
|
static int rrevbase;
|
||||||
static int rrerrbase;
|
static int rrerrbase;
|
||||||
static char *argv0;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
die(const char *errstr, ...)
|
die(const char *errstr, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
fputs("slock: ", stderr);
|
||||||
va_start(ap, errstr);
|
va_start(ap, errstr);
|
||||||
fprintf(stderr, "%s: ", argv0);
|
|
||||||
vfprintf(stderr, errstr, ap);
|
vfprintf(stderr, errstr, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -256,7 +255,7 @@ lockscreen(Display *dpy, int screen)
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
if (!len) {
|
if (!len) {
|
||||||
fprintf(stderr, "unable to grab mouse pointer for screen %d\n", screen);
|
fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n", screen);
|
||||||
} else {
|
} else {
|
||||||
for (len = 1000; len; len--) {
|
for (len = 1000; len; len--) {
|
||||||
if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) {
|
if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) {
|
||||||
|
@ -266,7 +265,7 @@ lockscreen(Display *dpy, int screen)
|
||||||
}
|
}
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "unable to grab keyboard for screen %d\n", screen);
|
fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", screen);
|
||||||
}
|
}
|
||||||
/* grabbing one of the inputs failed */
|
/* grabbing one of the inputs failed */
|
||||||
running = 0;
|
running = 0;
|
||||||
|
@ -283,8 +282,6 @@ main(int argc, char **argv)
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
argv0 = argv[0], argc--, argv++;
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
dontkillme();
|
dontkillme();
|
||||||
#endif
|
#endif
|
||||||
|
@ -317,11 +314,11 @@ main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 1 && fork() == 0) {
|
if (argc >= 2 && fork() == 0) {
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
execvp(argv[0], argv);
|
execvp(argv[1], argv+1);
|
||||||
die("execvp %s failed: %s\n", argv[0], strerror(errno));
|
die("execvp %s failed: %s\n", argv[1], strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Everything is now blank. Now wait for the correct password. */
|
/* Everything is now blank. Now wait for the correct password. */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user