eylles / vifm-sixel-preview

vifm image previews for sixel capable terminals
24 stars 1 forks source link

Use `2> /dev/null` to supress error messages for some special files #5

Open RayZ0rr opened 1 year ago

RayZ0rr commented 1 year ago

I am using this plugin with vifm and I have say it works great :heart: (my terminal is wezterm which has sizel capabilities)

Sometimes there are files such as password-protected pdf files. These files don't show preview but currently show a big error msg. This kinda messes up the display in the adjacent pane too.

So, maybe use > /dev/null for cleaner messages?

case "$action" in
  "clear")
    cleanup
    ;;
  "draw")
    [ ! -f "${PCACHE}.jpg" ] && convert "$image_file"'[0]' "${PCACHE}.jpg"
    # FILE="$PWD/$image_file"
    image "${PCACHE}.jpg" "$width" "$height" 2> /dev/null  <-- here
    ;;
  "video")
    [ ! -f "${PCACHE}.jpg" ] && \
    ffmpegthumbnailer -i "$4" -o "${PCACHE}.jpg" -s 0 -q 5
    image "${PCACHE}.jpg" "$width" "$height" 2> /dev/null  <-- here
    ;;
  "epub")
    [ ! -f "${PCACHE}.jpg" ] && \
    epub-thumbnailer "$image_file" "$PCACHE" 1024
    image "${PCACHE}.jpg" "$width" "$height" 2> /dev/null  <-- here
    ;;
  "pdf")
    [ ! -f "${PCACHE}.jpg" ] && \
    pdftoppm -jpeg -f 1 -singlefile "$image_file" "$PCACHE"
    image "${PCACHE}.jpg" "$width" "$height" 2> /dev/null  <-- here
    ;;
eylles commented 1 year ago

Ah thanks, i'm looking into improving this to have it do some stuf automagically with a wrapper but that is besides this issue.

Hmmm iirc there should be one utility that allowed to unlock password protected pdfs, think it was pdfjam but will look up once i get home.

RayZ0rr commented 1 year ago

Using a separate utility to preview special files, say password-protected pdfs, is a good idea. But I think it's better if these files, especially password-protected pdf files, don't show any preview because they might have sensitive content. In order to preview, it also gets cached which might not be desirable.

I think just redirecting the stderr would be sufficient as it also reduces your maintenance burden from adding more complexity(new utility to keep track of).

EDIT :- there was a typo in my first post and title. It should be 2> /dev/null instead of > /dev/null

eylles commented 1 year ago

Still got more to do on this, will try to push some of the changes i want to push this week and try to do the stderr redirection.