Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
allow window title to be set at runtime with -T option
Browse files Browse the repository at this point in the history
  • Loading branch information
defaultxr committed Dec 3, 2020
1 parent 1d28627 commit 2fea042
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions sxiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ struct opt {
long embed;
char *geometry;
char *res_name;
char *title;

/* misc flags: */
bool quiet;
Expand Down
2 changes: 1 addition & 1 deletion window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 2fea042

Please sign in to comment.