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

allow window title to be set at runtime with -T option #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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
5 changes: 5 additions & 0 deletions sxiv.1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ sxiv \- Simple X Image Viewer
.IR GEOMETRY ]
.RB [ \-N
.IR NAME ]
.RB [ \-T
.IR TITLE ]
.RB [ \-n
.IR NUM ]
.RB [ \-S
Expand Down Expand Up @@ -64,6 +66,9 @@ more information on GEOMETRY argument.
.BI "\-N " NAME
Set the resource name of sxiv's X window to NAME.
.TP
.BI "\-T " TITLE
Set the title of sxiv's X window to TITLE.
.TP
.BI "\-n " NUM
Start at picture number NUM.
.TP
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