diff --git a/man/timg.1.md b/man/timg.1.md index 3627b1e..d9dc799 100644 --- a/man/timg.1.md +++ b/man/timg.1.md @@ -179,9 +179,9 @@ these file decoders (GraphicsMagick or libav respectively). the opposite of **-V**. **-\-title=[format-string]** -: Print filename as title above each image. By default, this is just the - filename (`%f`), but it is possible to customize the title by giving a - format string. In this string, the following format specifiers are expanded +: Print title above each image. It is possible to customize the + title by giving a format string. In this string, the following format + specifiers are expanded: * `%f` = full filename * `%b` = basename (filename without path) @@ -189,8 +189,12 @@ these file decoders (GraphicsMagick or libav respectively). * `%h` = image height * `%D` = internal decoder used (image, video, ...) + If no format string is given, this is just the filename (`%f`) or, if + set, what is provided in the `TIMG_DEFAULT_TITLE` environment variable. + **-F** -: Behaves like --title=\"%f\", i.e. the filename is printed as title. +: Behaves like --title=\"%f\", i.e. the filename is printed as title + (or, if set, the `TIMG_DEFAULT_TITLE` environment variable). **-f** <*filelist-file*> : Read a list of image filenames to show from this file. The list needs @@ -283,8 +287,12 @@ Exit code is # ENVIRONMENT +**TIMG_DEFAULT_TITLE** +: The default format string used for `--title`. If not given, the default + title format string is \"`%f`\". + **TIMG_USE_UPPER_BLOCK** -: If this environment variable is set to the value **1**, timg will use the +: If this environment variable is set to the value **1**, timg will use the U+2580 - 'Upper Half Block' (▀) Unicode character. To display pixels, timg uses a Unicode half block and sets the foreground diff --git a/src/display-options.h b/src/display-options.h index 506939e..f8f57b3 100644 --- a/src/display-options.h +++ b/src/display-options.h @@ -17,6 +17,8 @@ #include "timg-time.h" +#include + #include #include #include @@ -31,6 +33,11 @@ static constexpr int kNotInitialized = std::numeric_limits::min(); // Options influencing the rendering, chosen on the command-line or // programmatically. struct DisplayOptions { + DisplayOptions() { + static constexpr const char *kFormatEnv = "TIMG_DEFAULT_TITLE"; + if (getenv(kFormatEnv)) title_format = getenv(kFormatEnv); + } + int width = -1; // Output size. These need to be set to... int height = -1; // ... valid values.