67
67
# Note: The exact package names providing these programs vary depending
68
68
# on your OS/distribution, but ususally they have the same name as the program.
69
69
70
- # ###########################
71
- # DEFAULT OPTIONS
72
- # ###########################
70
+ # -----------------------------
71
+ # 1. DEFAULT OPTIONS
72
+ # -----------------------------
73
73
74
- #
75
74
# Set the preview image method.
76
75
# Available methods: sixel, ueberzug, kitty, ansi (text mode)
77
76
#
@@ -84,12 +83,26 @@ method=""
84
83
# Available applications: chafa, pixterm, img2txt, viu, catimg, tiv, timg
85
84
ansi_method=" chafa"
86
85
87
- # To generate sixel images we use chafa(1).
86
+ # NOTE: To generate sixel images we use chafa(1).
88
87
89
88
type=" $1 "
90
89
file=" $2 "
91
90
file_URI=" ${3:- $file } "
92
91
92
+ # The maximum size for a thumbnail is, according to the Freedesktop specification
93
+ # (https://specifications.freedesktop.org/thumbnail-spec/latest/creation.html),
94
+ # 1024x1024. However, since we display thumbnails in a preview window, sometimes
95
+ # using half of the screen, we need a bigger resolution.
96
+ DEFAULT_SIZE=" 1920x1080"
97
+
98
+ # According to the Freedesktop specification, thumbnails should be in PNG format.
99
+ # However, some of the convertions below, mostly for PDF files, generate truncated
100
+ # images when converting to PNG (while quickly scrolling through the preview window).
101
+ # This is why, for the time being, we stick to JPG.
102
+ THUMB_FORMAT=" jpg"
103
+
104
+ # Because of the above observations, we cannot use any of the thumbnails directories
105
+ # specificied by the Freedesktop specification, but a custom one.
93
106
CACHE_DIR=" $CLIFM_THUMBNAILS_DIR "
94
107
[ -z " $CACHE_DIR " ] && CACHE_DIR=" ${XDG_CACHE_HOME:- $HOME / .cache} /clifm/thumbnails"
95
108
@@ -99,14 +112,13 @@ CACHEDIRTAG_HEADER="Signature: 8a477f597d28d172789f06886806bc55
99
112
# For information about cache directory tags, see:
100
113
# http://www.brynosaurus.com/cachedir/"
101
114
115
+ # This file contains information about generated thumbnails: for the time being,
116
+ # only the path to the original file (as a file URI).
102
117
THUMBINFO_FILE=" $CACHE_DIR /${CLIFM_THUMBINFO_FILE:- thumbnails.info} "
103
118
104
- DEFAULT_SIZE=" 1920x1080"
105
- THUMB_FORMAT=" jpg"
106
-
107
- # ###########################
108
- # SOME AUXILIARY FUNCTIONS
109
- # ###########################
119
+ # -----------------------------
120
+ # 2. SOME AUXILIARY FUNCTIONS
121
+ # -----------------------------
110
122
111
123
get_preview_method () {
112
124
if [ -z " $method " ]; then
@@ -153,9 +165,9 @@ add_to_info_file() {
153
165
return 0
154
166
}
155
167
156
- # ###########################
157
- # DISPLAY IMAGES
158
- # ###########################
168
+ # -----------------------------
169
+ # 3. DISPLAY IMAGES
170
+ # -----------------------------
159
171
160
172
display () {
161
173
[ -z " $1 " ] && exit 1
@@ -215,9 +227,9 @@ display() {
215
227
esac
216
228
}
217
229
218
- # ###########################
219
- # THUMBNAILS GENERATION
220
- # ###########################
230
+ # -----------------------------
231
+ # 4. THUMBNAILS GENERATION
232
+ # -----------------------------
221
233
222
234
gen_audio_preview () {
223
235
ffmpeg -hide_banner -i " $1 " " $2 " -y > /dev/null 2>&1 && \
@@ -308,9 +320,9 @@ gen_video_preview() {
308
320
print_err_msg " ffmpegthumbnailer" " $? " " video"
309
321
}
310
322
311
- # ###########################
312
- # MAIN
313
- # ###########################
323
+ # -----------------------------
324
+ # 4. MAIN
325
+ # -----------------------------
314
326
315
327
main () {
316
328
get_preview_method
0 commit comments