mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
swaylock: add i3lock compatible options
This commit is contained in:
parent
259dc25ba3
commit
7b25caba47
|
@ -92,28 +92,46 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
char *image_path = NULL;
|
||||||
|
char *scaling_mode_str = "fit";
|
||||||
|
|
||||||
init_log(L_INFO);
|
init_log(L_INFO);
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"image", required_argument, NULL, 'i'},
|
||||||
|
{"scaling", required_argument, NULL, 's'},
|
||||||
|
{"tiling", no_argument, NULL, 't'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *usage =
|
const char *usage =
|
||||||
"Usage: swaylock <image> [stretch|fit|fill|center|tile]\n"
|
"Usage: swaylock [options...]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -h, --help Show help message and quit.\n"
|
" -h, --help Show help message and quit.\n"
|
||||||
" -v, --version Show the version number and quit.\n";
|
" -s, --scaling Scaling mode: stretch, fill, fit, center, tile.\n"
|
||||||
|
" -t, --tiling Same as --scaling=tile.\n"
|
||||||
|
" -v, --version Show the version number and quit.\n"
|
||||||
|
" -i, --image <path> Display the given image.\n";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "hv", long_options, &option_index);
|
c = getopt_long(argc, argv, "hi:s:tv", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'i':
|
||||||
|
image_path = optarg;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
scaling_mode_str = optarg;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
scaling_mode_str = "tile";
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
|
#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
|
||||||
fprintf(stdout, "swaylock version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH);
|
fprintf(stdout, "swaylock version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH);
|
||||||
|
@ -128,8 +146,11 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *image_path = argv[optind];
|
// TODO: support locking without image
|
||||||
char *scaling_mode_str = argv[optind+1];
|
if (!image_path) {
|
||||||
|
fprintf(stderr, "No image specified!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
password = malloc(1024); // TODO: Let this grow
|
password = malloc(1024); // TODO: Let this grow
|
||||||
password[0] = '\0';
|
password[0] = '\0';
|
||||||
|
@ -154,7 +175,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
#ifdef WITH_GDK_PIXBUF
|
#ifdef WITH_GDK_PIXBUF
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(image_path, &err); // TODO: Parse i3lock arguments
|
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(image_path, &err);
|
||||||
if (!pixbuf) {
|
if (!pixbuf) {
|
||||||
sway_abort("Failed to load background image.");
|
sway_abort("Failed to load background image.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue