summaryrefslogtreecommitdiff
path: root/i3lock.c
diff options
context:
space:
mode:
authorVincent Bernat <bernat@luffy.cx>2013-08-26 23:39:38 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-08-31 20:41:12 +0200
commit5627a111746e96119e6789d8f8f47168b3a8c41d (patch)
treec29ffe1f6ebc10287daec4ba56bc47c324a18df0 /i3lock.c
parent3e136769beae3ef13ce492d341dbf3ff32c87ec9 (diff)
Add `-e` option to not validate empty password.
When the XF86ScreenSaver key is used to put a laptop to sleep (or to trigger the screensaver), the key may "bounce" on resume. This is annoying as i3lock will try to validate several empty passwords and wait several seconds before accepting a legit password. Some users may want to validate an empty password: PAM may rely on other sources to unlock the screen, like the presence of a token or the proximity of some Bluetooth device. Hence, we don't forbid this possibility and provide an command-line option for users not willing to validate empty passwords.
Diffstat (limited to 'i3lock.c')
-rw-r--r--i3lock.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/i3lock.c b/i3lock.c
index e5654d6..a4e0870 100644
--- a/i3lock.c
+++ b/i3lock.c
@@ -60,6 +60,7 @@ static struct xkb_keymap *xkb_keymap;
cairo_surface_t *img = NULL;
bool tile = false;
+bool ignore_empty_password = false;
/* isutf, u8_dec © 2005 Jeff Bezanson, public domain */
#define isutf(c) (((c) & 0xC0) != 0x80)
@@ -267,6 +268,10 @@ static void handle_key_press(xcb_key_press_event_t *event) {
case XKB_KEY_Return:
case XKB_KEY_KP_Enter:
case XKB_KEY_XF86ScreenSaver:
+ if (ignore_empty_password && input_position == 0) {
+ clear_input();
+ return;
+ }
password[input_position] = '\0';
unlock_state = STATE_KEY_PRESSED;
redraw_screen();
@@ -533,13 +538,14 @@ int main(int argc, char *argv[]) {
{"no-unlock-indicator", no_argument, NULL, 'u'},
{"image", required_argument, NULL, 'i'},
{"tiling", no_argument, NULL, 't'},
+ {"ignore-empty-password", no_argument, NULL, 'e'},
{NULL, no_argument, NULL, 0}
};
if ((username = getenv("USER")) == NULL)
errx(1, "USER environment variable not set, please set it.\n");
- while ((o = getopt_long(argc, argv, "hvnbdc:p:ui:t", longopts, &optind)) != -1) {
+ while ((o = getopt_long(argc, argv, "hvnbdc:p:ui:te", longopts, &optind)) != -1) {
switch (o) {
case 'v':
errx(EXIT_SUCCESS, "version " VERSION " © 2010-2012 Michael Stapelberg");
@@ -582,6 +588,9 @@ int main(int argc, char *argv[]) {
errx(1, "i3lock: Invalid pointer type given. Expected one of \"win\" or \"default\".\n");
}
break;
+ case 'e':
+ ignore_empty_password = true;
+ break;
case 0:
if (strcmp(longopts[optind].name, "debug") == 0)
debug_mode = true;