New option: -N, set X window resource name

This commit is contained in:
Bert Münnich 2012-10-29 00:53:50 +01:00
parent 65d5d44696
commit 6f9b4f5b2e
5 changed files with 14 additions and 3 deletions

View File

@ -68,6 +68,7 @@ sxiv supports the following command-line options:
-g GEOMETRY Set window position and size -g GEOMETRY Set window position and size
(see section GEOMETRY SPECIFICATIONS of X(7)) (see section GEOMETRY SPECIFICATIONS of X(7))
-n NUM Start at picture NUM -n NUM Start at picture NUM
-N NAME Set X window resource name to NAME
-p Pixelize, i.e. turn off image anti-aliasing -p Pixelize, i.e. turn off image anti-aliasing
-q Be quiet, disable warnings -q Be quiet, disable warnings
-r Search given directories recursively for images -r Search given directories recursively for images

View File

@ -33,7 +33,7 @@ const options_t *options = (const options_t*) &_options;
void print_usage(void) { void print_usage(void) {
printf("usage: sxiv [-bcdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] " printf("usage: sxiv [-bcdFfhpqrstvZ] [-g GEOMETRY] [-n NUM] "
"[-z ZOOM] FILES...\n"); "[-N name] [-z ZOOM] FILES...\n");
} }
void print_version(void) { void print_version(void) {
@ -54,12 +54,13 @@ void parse_options(int argc, char **argv) {
_options.fullscreen = false; _options.fullscreen = false;
_options.hide_bar = false; _options.hide_bar = false;
_options.geometry = NULL; _options.geometry = NULL;
_options.res_name = NULL;
_options.quiet = false; _options.quiet = false;
_options.thumb_mode = false; _options.thumb_mode = false;
_options.clean_cache = false; _options.clean_cache = false;
while ((opt = getopt(argc, argv, "bcdFfg:hn:pqrstvZz:")) != -1) { while ((opt = getopt(argc, argv, "bcdFfg:hn:N:pqrstvZz:")) != -1) {
switch (opt) { switch (opt) {
case '?': case '?':
print_usage(); print_usage();
@ -94,6 +95,9 @@ void parse_options(int argc, char **argv) {
_options.startnum = t - 1; _options.startnum = t - 1;
} }
break; break;
case 'N':
_options.res_name = optarg;
break;
case 'p': case 'p':
_options.aa = false; _options.aa = false;
break; break;

View File

@ -40,6 +40,7 @@ typedef struct {
bool fullscreen; bool fullscreen;
bool hide_bar; bool hide_bar;
char *geometry; char *geometry;
char *res_name;
/* misc flags: */ /* misc flags: */
bool quiet; bool quiet;

5
sxiv.1
View File

@ -8,6 +8,8 @@ sxiv \- Simple (or small or suckless) X Image Viewer
.IR GEOMETRY ] .IR GEOMETRY ]
.RB [ \-n .RB [ \-n
.IR NUM ] .IR NUM ]
.RB [ \-N
.IR NAME ]
.RB [ \-z .RB [ \-z
.IR ZOOM ] .IR ZOOM ]
.IR FILE ... .IR FILE ...
@ -57,6 +59,9 @@ more information on
.BI "\-n " NUM .BI "\-n " NUM
Start at picture number NUM. Start at picture number NUM.
.TP .TP
.BI "\-N " NAME
Set the resource name of sxiv's X window to NAME.
.TP
.B \-h .B \-h
Print brief usage information to standard output and exit. Print brief usage information to standard output and exit.
.TP .TP

View File

@ -207,8 +207,8 @@ void win_open(win_t *win) {
win_set_title(win, "sxiv"); win_set_title(win, "sxiv");
classhint.res_name = "sxiv";
classhint.res_class = "Sxiv"; classhint.res_class = "Sxiv";
classhint.res_name = options->res_name != NULL ? options->res_name : "sxiv";
XSetClassHint(e->dpy, win->xwin, &classhint); XSetClassHint(e->dpy, win->xwin, &classhint);
XSetWMProtocols(e->dpy, win->xwin, &wm_delete_win, 1); XSetWMProtocols(e->dpy, win->xwin, &wm_delete_win, 1);