Skip to content

Commit

Permalink
Display help on wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
orestisfl committed May 22, 2024
1 parent a7ebe81 commit aa49e44
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions i3lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,13 +1006,7 @@ int main(int argc, char *argv[]) {
{"show-keyboard-layout", no_argument, NULL, 'k'},
{NULL, no_argument, NULL, 0}};

if ((pw = getpwuid(getuid())) == NULL)
err(EXIT_FAILURE, "getpwuid() failed");
if ((username = pw->pw_name) == NULL)
errx(EXIT_FAILURE, "pw->pw_name is NULL.");
if (getenv("WAYLAND_DISPLAY") != NULL)
errx(EXIT_FAILURE, "i3lock is a program for X11 and does not work on Wayland. Try https://github.com/swaywm/swaylock instead");

int code = EXIT_FAILURE;
char *optstring = "hvnbdc:p:ui:teI:fk";
while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) {
switch (o) {
Expand Down Expand Up @@ -1076,12 +1070,26 @@ int main(int argc, char *argv[]) {
case 'k':
show_keyboard_layout = true;
break;
case 'h':
code = EXIT_SUCCESS;
/* fallthrough */
default:
errx(EXIT_FAILURE, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
" [-i image.png] [-t] [-e] [-I timeout] [-f] [-k]");
errx(code, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
" [-i image.png] [-t] [-e] [-I timeout] [-f] [-k]");
}
}

if ((pw = getpwuid(getuid())) == NULL) {
err(EXIT_FAILURE, "getpwuid() failed");
}
if ((username = pw->pw_name) == NULL) {
errx(EXIT_FAILURE, "pw->pw_name is NULL.");
}
if (getenv("WAYLAND_DISPLAY") != NULL) {
errx(EXIT_FAILURE, "i3lock is a program for X11 and does not work on Wayland. Try https://github.com/swaywm/swaylock instead");
}


/* We need (relatively) random numbers for highlighting a random part of
* the unlock indicator upon keypresses. */
srand(time(NULL));
Expand Down

0 comments on commit aa49e44

Please sign in to comment.