Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display help on wayland #358

Merged
merged 1 commit into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 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,25 @@ 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
Loading