From 2fea0426e253d7b14e4ac9a43d7603e79e5e4af1 Mon Sep 17 00:00:00 2001 From: "modula t. worm" Date: Wed, 2 Dec 2020 23:24:32 -0600 Subject: [PATCH] allow window title to be set at runtime with -T option --- options.c | 10 +++++++--- sxiv.h | 1 + window.c | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/options.c b/options.c index de024075..9922fb7e 100644 --- a/options.c +++ b/options.c @@ -31,8 +31,8 @@ const opt_t *options = (const opt_t*) &_options; void print_usage(void) { printf("usage: sxiv [-abcfhiopqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] " - "[-g GEOMETRY] [-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] " - "FILES...\n"); + "[-g GEOMETRY] [-N NAME] [-T TITLE] [-n NUM] [-S DELAY] [-s MODE] " + "[-z ZOOM] FILES...\n"); } void print_version(void) @@ -66,13 +66,14 @@ void parse_options(int argc, char **argv) _options.hide_bar = false; _options.geometry = NULL; _options.res_name = NULL; + _options.title = NULL; _options.quiet = false; _options.thumb_mode = false; _options.clean_cache = false; _options.private_mode = false; - while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:opqrS:s:tvZz:")) != -1) { + while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:opqrS:s:tT:vZz:")) != -1) { switch (opt) { case '?': print_usage(); @@ -149,6 +150,9 @@ void parse_options(int argc, char **argv) error(EXIT_FAILURE, 0, "Invalid argument for option -s: %s", optarg); _options.scalemode = s - scalemodes; break; + case 'T': + _options.title = optarg; + break; case 't': _options.thumb_mode = true; break; diff --git a/sxiv.h b/sxiv.h index 707eba71..d27be16d 100644 --- a/sxiv.h +++ b/sxiv.h @@ -279,6 +279,7 @@ struct opt { long embed; char *geometry; char *res_name; + char *title; /* misc flags: */ bool quiet; diff --git a/window.c b/window.c index 6f9a3906..10ba2724 100644 --- a/window.c +++ b/window.c @@ -238,7 +238,7 @@ void win_open(win_t *win) } free(icon_data); - win_set_title(win, "sxiv"); + win_set_title(win, options->title != NULL ? options->title : "sxiv"); classhint.res_class = RES_CLASS; classhint.res_name = options->res_name != NULL ? options->res_name : "sxiv";