nsxiv6f9b4f5
New option: -N, set X window resource name
+14 −3
5 files changed
| @@ -68,6 +68,7 @@ sxiv supports the following command-line options: | |||
| 68 | 68 | -g GEOMETRY Set window position and size | |
| 69 | 69 | (see section GEOMETRY SPECIFICATIONS of X(7)) | |
| 70 | 70 | -n NUM Start at picture NUM | |
| 71 | + | -N NAME Set X window resource name to NAME | |
| 71 | 72 | -p Pixelize, i.e. turn off image anti-aliasing | |
| 72 | 73 | -q Be quiet, disable warnings | |
| 73 | 74 | -r Search given directories recursively for images | |
| @@ -33,7 +33,7 @@ const options_t *options = (const options_t*) &_options; | |||
| 33 | 33 | ||
| 34 | 34 | void print_usage(void) { | |
| 35 | 35 | printf("usage: sxiv [-bcdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] " | |
| 36 | − | "[-z ZOOM] FILES...\n"); | |
| 36 | + | "[-N name] [-z ZOOM] FILES...\n"); | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | 39 | void print_version(void) { | |
| @@ -54,12 +54,13 @@ void parse_options(int argc, char **argv) { | |||
| 54 | 54 | _options.fullscreen = false; | |
| 55 | 55 | _options.hide_bar = false; | |
| 56 | 56 | _options.geometry = NULL; | |
| 57 | + | _options.res_name = NULL; | |
| 57 | 58 | ||
| 58 | 59 | _options.quiet = false; | |
| 59 | 60 | _options.thumb_mode = false; | |
| 60 | 61 | _options.clean_cache = false; | |
| 61 | 62 | ||
| 62 | − | while ((opt = getopt(argc, argv, "bcdFfg:hn:pqrstvZz:")) != -1) { | |
| 63 | + | while ((opt = getopt(argc, argv, "bcdFfg:hn:N:pqrstvZz:")) != -1) { | |
| 63 | 64 | switch (opt) { | |
| 64 | 65 | case '?': | |
| 65 | 66 | print_usage(); | |
| @@ -94,6 +95,9 @@ void parse_options(int argc, char **argv) { | |||
| 94 | 95 | _options.startnum = t - 1; | |
| 95 | 96 | } | |
| 96 | 97 | break; | |
| 98 | + | case 'N': | |
| 99 | + | _options.res_name = optarg; | |
| 100 | + | break; | |
| 97 | 101 | case 'p': | |
| 98 | 102 | _options.aa = false; | |
| 99 | 103 | break; | |
| @@ -40,6 +40,7 @@ typedef struct { | |||
| 40 | 40 | bool fullscreen; | |
| 41 | 41 | bool hide_bar; | |
| 42 | 42 | char *geometry; | |
| 43 | + | char *res_name; | |
| 43 | 44 | ||
| 44 | 45 | /* misc flags: */ | |
| 45 | 46 | bool quiet; | |
| @@ -8,6 +8,8 @@ sxiv \- Simple (or small or suckless) X Image Viewer | |||
| 8 | 8 | .IR GEOMETRY ] | |
| 9 | 9 | .RB [ \-n | |
| 10 | 10 | .IR NUM ] | |
| 11 | + | .RB [ \-N | |
| 12 | + | .IR NAME ] | |
| 11 | 13 | .RB [ \-z | |
| 12 | 14 | .IR ZOOM ] | |
| 13 | 15 | .IR FILE ... | |
| @@ -57,6 +59,9 @@ more information on | |||
| 57 | 59 | .BI "\-n " NUM | |
| 58 | 60 | Start at picture number NUM. | |
| 59 | 61 | .TP | |
| 62 | + | .BI "\-N " NAME | |
| 63 | + | Set the resource name of sxiv's X window to NAME. | |
| 64 | + | .TP | |
| 60 | 65 | .B \-h | |
| 61 | 66 | Print brief usage information to standard output and exit. | |
| 62 | 67 | .TP | |
| @@ -207,8 +207,8 @@ void win_open(win_t *win) { | |||
| 207 | 207 | ||
| 208 | 208 | win_set_title(win, "sxiv"); | |
| 209 | 209 | ||
| 210 | − | classhint.res_name = "sxiv"; | |
| 211 | 210 | classhint.res_class = "Sxiv"; | |
| 211 | + | classhint.res_name = options->res_name != NULL ? options->res_name : "sxiv"; | |
| 212 | 212 | XSetClassHint(e->dpy, win->xwin, &classhint); | |
| 213 | 213 | ||
| 214 | 214 | XSetWMProtocols(e->dpy, win->xwin, &wm_delete_win, 1); | |