Krolyxon
Commit ecc363e

Branches

Refs →

nsxivecc363e

Add -p flag to disable writing of cache and temporary files

Closes #285.
Author
Antti Korpi
Date
2017-07-13 01:15 +0100
Committer
Bert Münnich · 2017-09-08 22:04 +0200
Parent
20009c2
Commit
ecc363ec10dec864dd2c956b478549ff235fb3d6

+16 −4

4 files changed

  1. M options.c +6 −2
  2. M options.h +1 −0
  3. M sxiv.1 +4 −1
  4. M thumbs.c +5 −1
M options.c View
@@ -32,7 +32,7 @@ const options_t *options = (const options_t*) &_options;
3232
3333 void print_usage(void)
3434 {
35− printf("usage: sxiv [-abcfhioqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] "
35+ printf("usage: sxiv [-abcfhiopqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] "
3636 "[-g GEOMETRY] [-N NAME] [-n NUM] [-S DELAY] [-s MODE] [-z ZOOM] "
3737 "FILES...\n");
3838 }
@@ -72,8 +72,9 @@ void parse_options(int argc, char **argv)
7272 _options.quiet = false;
7373 _options.thumb_mode = false;
7474 _options.clean_cache = false;
75+ _options.private_mode = false;
7576
76− while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:oqrS:s:tvZz:")) != -1) {
77+ while ((opt = getopt(argc, argv, "A:abce:fG:g:hin:N:opqrS:s:tvZz:")) != -1) {
7778 switch (opt) {
7879 case '?':
7980 print_usage();
@@ -129,6 +130,9 @@ void parse_options(int argc, char **argv)
129130 case 'o':
130131 _options.to_stdout = true;
131132 break;
133+ case 'p':
134+ _options.private_mode = true;
135+ break;
132136 case 'q':
133137 _options.quiet = true;
134138 break;
M options.h View
@@ -50,6 +50,7 @@ typedef struct {
5050 bool quiet;
5151 bool thumb_mode;
5252 bool clean_cache;
53+ bool private_mode;
5354 } options_t;
5455
5556 extern const options_t *options;
M sxiv.1 View
@@ -3,7 +3,7 @@
33 sxiv \- Simple X Image Viewer
44 .SH SYNOPSIS
55 .B sxiv
6−.RB [ \-abcfhioqrtvZ ]
6+.RB [ \-abcfhiopqrtvZ ]
77 .RB [ \-A
88 .IR FRAMERATE ]
99 .RB [ \-e
@@ -80,6 +80,9 @@ with
8080 .B \-i
8181 sxiv can be used as a visual filter/pipe.
8282 .TP
83+.B \-p
84+Enable private mode, in which sxiv does not write any cache or temporary files.
85+.TP
8386 .B \-q
8487 Be quiet, disable warnings to standard error stream.
8588 .TP
M thumbs.c View
@@ -25,6 +25,7 @@
2525 #include <unistd.h>
2626 #include <utime.h>
2727
28+#include "options.h"
2829 #include "thumbs.h"
2930 #include "util.h"
3031
@@ -83,6 +84,9 @@ void tns_cache_write(Imlib_Image im, const char *filepath, bool force)
8384 struct utimbuf times;
8485 Imlib_Load_Error err = 0;
8586
87+ if (options->private_mode)
88+ return;
89+
8690 if (stat(filepath, &fstats) < 0)
8791 return;
8892
@@ -270,7 +274,7 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
270274 cache_hit = true;
271275 }
272276 #if HAVE_LIBEXIF
273− } else if (!force) {
277+ } else if (!force && !options->private_mode) {
274278 int pw = 0, ph = 0, w, h, x = 0, y = 0;
275279 bool err;
276280 float zw, zh;