Control: tags -1 + confirmed patch

Moritz Muehlenhoff wrote on Sat, Dec 05, 2015 at 12:21:12 +0100:
> On Sat, Dec 05, 2015 at 10:13:14AM +0000, Daniel Shahaf wrote:
> > fbi prints messages to stderr in successful operation:
> > 
> >     % fbi foo.jpg >/dev/null
> >     using "Inconsolata-16", pixelsize=16.67 
> > file=/usr/share/fonts/truetype/inconsolata/Inconsolata.otf
> >     map: vt05 => fb0
> >     % fbi --noverbose foo.jpg >/dev/null
> >     using "Inconsolata-16", pixelsize=16.67 
> > file=/usr/share/fonts/truetype/inconsolata/Inconsolata.otf
> >     map: vt05 => fb0
> > 
> > Please disable such output (at least via an option).  There is already
> > a --verbose flag; perhaps the messages could be displayed in --verbose
> > mode only.
> 
> Patch welcome :-)
> 
> Cheers,
>         Moritz

Here you go. :-)

Thanks for your work!

Daniel


(patch written against 2.10-2)
--- a/fb-gui.c
+++ b/fb-gui.c
@@ -14,6 +14,7 @@
 #include "fbtools.h"
 #include "dither.h"
 #include "fb-gui.h"
+#include "fbiconfig.h"
 
 /* public */
 int visible = 1;
@@ -648,7 +649,8 @@
     /* try get the face directly */
     result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &face);
     if (FcResultMatch == result) {
-       fprintf(stderr,"using \"%s\", face=%p\n",fontname,face);
+       if (GET_DEBUG())
+           fprintf(stderr,"using \"%s\", face=%p\n",fontname,face);
        return face;
     }
 
@@ -658,8 +660,9 @@
        result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixelsize);
        if (FcResultMatch != result)
            pixelsize = 16;
-       fprintf(stderr,"using \"%s\", pixelsize=%.2lf file=%s\n",
-               fontname,pixelsize,filename);
+       if (GET_DEBUG())
+           fprintf(stderr,"using \"%s\", pixelsize=%.2lf file=%s\n",
+                   fontname,pixelsize,filename);
        rc = FT_New_Face (freetype, filename, 0, &face);
        if (rc)
            return NULL;
--- a/fbtools.c
+++ b/fbtools.c
@@ -23,6 +23,7 @@
 #include <linux/fb.h>
 
 #include "fbtools.h"
+#include "fbiconfig.h"
 
 #ifndef HAVE_STRSIGNAL
 static const char *strsignal(int signr)
@@ -357,8 +358,9 @@
                exit(1);
            }
            close(fb);
-           fprintf(stderr,"map: vt%02d => fb%d\n",
-                   c2m.console, c2m.framebuffer);
+           if (GET_DEBUG())
+               fprintf(stderr,"map: vt%02d => fb%d\n",
+                       c2m.console, c2m.framebuffer);
            sprintf(fbdev,devices->fbnr,c2m.framebuffer);
            device = fbdev;
        }
--- a/fbiconfig.h
+++ b/fbiconfig.h
@@ -15,6 +15,7 @@
 #define O_FIT_WIDTH            O_OPTIONS, "fit-width"
 #define O_QUIET                        O_OPTIONS, "quiet"
 #define O_VERBOSE              O_OPTIONS, "verbose"
+#define O_DEBUG                        O_OPTIONS, "debug"
 #define O_RANDOM               O_OPTIONS, "random"
 #define O_ONCE                 O_OPTIONS, "once"
 #define O_COMMENTS             O_OPTIONS, "comments"
@@ -47,6 +48,7 @@
 #define GET_FIT_WIDTH()                cfg_get_bool(O_FIT_WIDTH,     0)
 #define GET_QUIET()            cfg_get_bool(O_QUIET,         0)
 #define GET_VERBOSE()          cfg_get_bool(O_VERBOSE,       1)
+#define GET_DEBUG()            cfg_get_bool(O_DEBUG,         0)
 #define GET_RANDOM()           cfg_get_bool(O_RANDOM,        0)
 #define GET_ONCE()             cfg_get_bool(O_ONCE,          0)
 #define GET_COMMENTS()         cfg_get_bool(O_COMMENTS,      0)
--- a/fbiconfig.c
+++ b/fbiconfig.c
@@ -74,6 +74,11 @@
        .yesno    = 1,
        .desc     = "show filenames all the time",
     },{
+       .cmdline  = "debug",
+       .option   = { O_DEBUG },
+       .yesno    = 1,
+       .desc     = "show debugging information on stderr",
+    },{
        .letter   = 'u',
        .cmdline  = "random",
        .option   = { O_RANDOM },
--- a/fbi.man
+++ b/fbi.man
@@ -61,6 +61,9 @@
 Be verbose: enable status line on the bottom of the screen (enabled by
 default).
 .TP
+.B --(no)debug
+Print debug messages to stderr (disabled by default).
+.TP
 .B -u, --(no)random
 Randomize the order of the filenames.
 .TP

Reply via email to