Krolyxon
Commit 6f9b4f5

Branches

Refs →

nsxiv6f9b4f5

New option: -N, set X window resource name

Author
Bert Münnich
Date
2012-10-29 00:53 +0100
Committer
Bert Münnich · 2012-10-29 18:32 +0100
Parent
65d5d44
Commit
6f9b4f5b2ed5a82ad4711d1add9ccd620d8526ba

+14 −3

5 files changed

  1. M README.md +1 −0
  2. M options.c +6 −2
  3. M options.h +1 −0
  4. M sxiv.1 +5 −0
  5. M window.c +1 −1
M README.md View
@@ -68,6 +68,7 @@ sxiv supports the following command-line options:
6868 -g GEOMETRY Set window position and size
6969 (see section GEOMETRY SPECIFICATIONS of X(7))
7070 -n NUM Start at picture NUM
71+ -N NAME Set X window resource name to NAME
7172 -p Pixelize, i.e. turn off image anti-aliasing
7273 -q Be quiet, disable warnings
7374 -r Search given directories recursively for images
M options.c View
@@ -33,7 +33,7 @@ const options_t *options = (const options_t*) &_options;
3333
3434 void print_usage(void) {
3535 printf("usage: sxiv [-bcdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] "
36− "[-z ZOOM] FILES...\n");
36+ "[-N name] [-z ZOOM] FILES...\n");
3737 }
3838
3939 void print_version(void) {
@@ -54,12 +54,13 @@ void parse_options(int argc, char **argv) {
5454 _options.fullscreen = false;
5555 _options.hide_bar = false;
5656 _options.geometry = NULL;
57+ _options.res_name = NULL;
5758
5859 _options.quiet = false;
5960 _options.thumb_mode = false;
6061 _options.clean_cache = false;
6162
62− while ((opt = getopt(argc, argv, "bcdFfg:hn:pqrstvZz:")) != -1) {
63+ while ((opt = getopt(argc, argv, "bcdFfg:hn:N:pqrstvZz:")) != -1) {
6364 switch (opt) {
6465 case '?':
6566 print_usage();
@@ -94,6 +95,9 @@ void parse_options(int argc, char **argv) {
9495 _options.startnum = t - 1;
9596 }
9697 break;
98+ case 'N':
99+ _options.res_name = optarg;
100+ break;
97101 case 'p':
98102 _options.aa = false;
99103 break;
M options.h View
@@ -40,6 +40,7 @@ typedef struct {
4040 bool fullscreen;
4141 bool hide_bar;
4242 char *geometry;
43+ char *res_name;
4344
4445 /* misc flags: */
4546 bool quiet;
M sxiv.1 View
@@ -8,6 +8,8 @@ sxiv \- Simple (or small or suckless) X Image Viewer
88 .IR GEOMETRY ]
99 .RB [ \-n
1010 .IR NUM ]
11+.RB [ \-N
12+.IR NAME ]
1113 .RB [ \-z
1214 .IR ZOOM ]
1315 .IR FILE ...
@@ -57,6 +59,9 @@ more information on
5759 .BI "\-n " NUM
5860 Start at picture number NUM.
5961 .TP
62+.BI "\-N " NAME
63+Set the resource name of sxiv's X window to NAME.
64+.TP
6065 .B \-h
6166 Print brief usage information to standard output and exit.
6267 .TP
M window.c View
@@ -207,8 +207,8 @@ void win_open(win_t *win) {
207207
208208 win_set_title(win, "sxiv");
209209
210− classhint.res_name = "sxiv";
211210 classhint.res_class = "Sxiv";
211+ classhint.res_name = options->res_name != NULL ? options->res_name : "sxiv";
212212 XSetClassHint(e->dpy, win->xwin, &classhint);
213213
214214 XSetWMProtocols(e->dpy, win->xwin, &wm_delete_win, 1);