arguments.
This commit is contained in:
parent
cea569bdb4
commit
1d0a7a4d39
27
slock.c
27
slock.c
@ -28,6 +28,7 @@
|
|||||||
#define SLOCK_SHUTDOWN 1
|
#define SLOCK_SHUTDOWN 1
|
||||||
|
|
||||||
char *g_pw = NULL;
|
char *g_pw = NULL;
|
||||||
|
int alt_kill = 1;
|
||||||
int lock_tries = 0;
|
int lock_tries = 0;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -207,12 +208,13 @@ readpw(Display *dpy, const char *pws)
|
|||||||
case XK_F10:
|
case XK_F10:
|
||||||
case XK_F11:
|
case XK_F11:
|
||||||
case XK_F12:
|
case XK_F12:
|
||||||
case XK_F13: {
|
case XK_F13:
|
||||||
// Needs sudo privileges for systemctl
|
// Needs sudo privileges for systemctl
|
||||||
char *args[] = { "sudo", "systemctl", "poweroff", NULL };
|
if (alt_kill) {
|
||||||
execvp("sudo", args);
|
char *args[] = { "sudo", "systemctl", "poweroff", NULL };
|
||||||
// fall-through if we fail
|
execvp("sudo", args);
|
||||||
}
|
// fall-through if we fail
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
if(num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) {
|
if(num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) {
|
||||||
@ -351,15 +353,12 @@ main(int argc, char **argv) {
|
|||||||
freopen("/dev/null", "a", stderr);
|
freopen("/dev/null", "a", stderr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc < 2) {
|
char buf[255] = {0};
|
||||||
char buf[255] = {0};
|
snprintf(buf, sizeof(buf), "%s/.slock_passwd", getenv("HOME"));
|
||||||
snprintf(buf, sizeof(buf), "%s/.slock_passwd", getenv("HOME"));
|
g_pw = read_pfile(buf);
|
||||||
g_pw = read_pfile(buf);
|
|
||||||
} else if((argc >= 2) && !strcmp("-p", argv[1])) {
|
if((argc > 1) && !strcmp("-n", argv[1])) {
|
||||||
g_pw = strdup(argv[2]);
|
alt_kill = 0;
|
||||||
} else if((argc >= 2) && !strcmp("-f", argv[1])) {
|
|
||||||
g_pw = read_pfile(argv[2]);
|
|
||||||
if (g_pw == NULL) return 1;
|
|
||||||
} else if((argc >= 2) && !strcmp("-v", argv[1])) {
|
} else if((argc >= 2) && !strcmp("-v", argv[1])) {
|
||||||
die("slock-%s, © 2006-2012 Anselm R Garbe\n", VERSION);
|
die("slock-%s, © 2006-2012 Anselm R Garbe\n", VERSION);
|
||||||
} else if(argc != 1) {
|
} else if(argc != 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user