You are not logged in.

#1 2015-10-01 13:32:56

rjoukecu
Member
Registered: 2015-10-01
Posts: 5

i3 + Ranger - No file prewievs at all

Hello eveybody,
for some reason, Ranger doesn't show ANY file previews at all (images, videos, pdf, txts..), exept previews for folders big_smile.
I just don't know, if I messed up/missed something, or it is some kind of larger problem.

  GNU nano 2.4.2                 File: .config/ranger/scope.sh                                         

#!/usr/bin/env sh
# ranger supports enhanced previews.  If the option "use_preview_script"
# is set to True and this file exists, this script will be called and its
# output is displayed in ranger.  ANSI color codes are supported.

# NOTES: This script is considered a configuration file.  If you upgrade
# ranger, it will be left untouched. (You must update it yourself.)
# Also, ranger disables STDIN here, so interactive scripts won't work properly

# Meanings of exit codes:
# code | meaning    | action of ranger
# -----+------------+-------------------------------------------
# 0    | success    | success. display stdout as preview
# 1    | no preview | failure. display no preview at all
# 2    | plain text | display the plain content of the file
# 3    | fix width  | success. Don't reload when width changes
# 4    | fix height | success. Don't reload when height changes
# 5    | fix both   | success. Don't ever reload
# 6    | image      | success. display the image $cached points to as an image preview

# Meaningful aliases for arguments:
path="$1"    # Full path of the selected file
width="$2"   # Width of the preview pane (number of fitting characters)
height="$3"  # Height of the preview pane (number of fitting characters)
cached="$4"  # Path that should be used to cache image previews

maxln=200    # Stop after $maxln lines.  Can be used like ls | head -n $maxln

# Find out something about the file:
mimetype=$(file --mime-type -Lb "$path")
extension=$(/bin/echo -E "${path##*.}" | tr "[:upper:]" "[:lower:]")

# Functions:
# runs a command and saves its output into $output.  Useful if you need
# the return value AND want to use the output in a pipe
try() { output=$(eval '"$@"'); }

# writes the output of the previously used "try" command
dump() { /bin/echo -E "$output"; }

# a common post-processing function used after most commands
trim() { head -n "$maxln"; }

# wraps highlight to treat exit code 141 (killed by SIGPIPE) as success
highlight() { command highlight "$@"; test $? = 0 -o $? = 141; }

case "$extension" in
    # Archive extensions:
    7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
    rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
        try als "$path" && { dump | trim; exit 0; }
        try acat "$path" && { dump | trim; exit 3; }
        try bsdtar -lf "$path" && { dump | trim; exit 0; }
        exit 1;;
    rar)
        try unrar -p- lt "$path" && { dump | trim; exit 0; } || exit 1;;
    # PDF documents:
    pdf)
        try pdftotext -l 10 -nopgbrk -q "$path" - && \
            { dump | trim | fmt -s -w $width; exit 0; } || exit 1;;
    # BitTorrent Files
    torrent)
        try transmission-show "$path" && { dump | trim; exit 5; } || exit 1;;
    # HTML Pages:
    htm|html|xhtml)
        try w3m    -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
        try lynx   -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
        try elinks -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
        ;; # fall back to highlight/cat if the text browsers fail
esac

case "$mimetype" in
    # Syntax highlight for text files:
    text/* | */xml)
        try highlight --out-format=ansi "$path" && { dump | trim; exit 5; } || exit 2;;
    # Ascii-previews of images:
    image/*)
        img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;;
    # Image preview for videos, disabled by default:
     video/*)
         ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
    # Display information about media files:
    video/* | audio/*)
        exiftool "$path" && exit 5
        # Use sed to remove spaces so the output fits into the narrow window
        try mediainfo "$path" && { dump | trim | sed 's/  \+:/: /;';  exit 5; } || exit 1;;
esac

exit 1
  GNU nano 2.4.2                 File: .config/ranger/rc.conf                                          

# ===================================================================
# This file contains the default startup commands for ranger.
# To change them, it is recommended to create the file
# ~/.config/ranger/rc.conf and add your custom commands there.
#
# If you copy this whole file there, you may want to set the environment
# variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice.
#
# The purpose of this file is mainly to define keybindings and settings.
# For running more complex python code, please create a plugin in "plugins/" or
# a command in "commands.py".
#
# Each line is a command that will be run before the user interface
# is initialized.  As a result, you can not use commands which rely
# on the UI such as :delete or :mark.
# ===================================================================

# ===================================================================
# == Options
# ===================================================================

# How many columns are there, and what are their relative widths?
set column_ratios 1,3,4

# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$

# Show hidden files? You can toggle this by typing 'zh'
set show_hidden false

# Ask for a confirmation when running the "delete" command?
# Valid values are "always", "never", "multiple" (default)
# With "multiple", ranger will ask only if you delete multiple files at once.
set confirm_on_delete multiple

# Which script is used to generate file previews?
# ranger ships with scope.sh, a script that calls external programs (see
# README.md for dependencies) to preview images, archives, etc.
set preview_script ~/.config/ranger/scope.sh

# Use the external preview script or display simple plain text or image previews?
set use_preview_script true

# Automatically count files in the directory, even before entering them?
set automatically_count_files true

# Open all images in this directory when running certain image viewers
# like feh or sxiv?  You can still open selected files by marking them.
set open_all_images true

# Be aware of version control systems and display information.
set vcs_aware false

# State of the three backends git, hg, bzr. The possible states are
# disabled, local (only show local info), enabled (show local and remote
# information).
set vcs_backend_git enabled
set vcs_backend_hg disabled
set vcs_backend_bzr disabled

# Use one of the supported image preview protocols
set preview_images true

# Set the preview image method. Supported methods:
#
# * w3m (default):
#   Preview images in full color with the external command "w3mimgpreview"?
#   This requires the console web browser "w3m" and a supported terminal.
#   It has been successfully tested with "xterm" and "urxvt" without tmux.
#
# * iterm2:
#   Preview images in full color using iTerm2 image previews
#   (http://iterm2.com/images.html). This requires using iTerm2 compiled
#   with image preview support.
set preview_images_method w3m

# Use a unicode "..." character to mark cut-off filenames?
set unicode_ellipsis false

# Show dotfiles in the bookmark preview box?
set show_hidden_bookmarks true

# Which colorscheme to use?  These colorschemes are available by default:
# default, jungle, snow, solarized
set colorscheme default

# Preview files on the rightmost column?
# And collapse (shrink) the last column if there is nothing to preview?
set preview_files true
set preview_directories true
set collapse_preview true

# Save the console history on exit?
set save_console_history true

# Draw the status bar on top of the browser window (default: bottom)
set status_bar_on_top false

# Draw a progress bar in the status bar which displays the average state of all
# currently running tasks which support progress bars?
set draw_progress_bar_in_status_bar true

# Draw borders around columns?
set draw_borders false

# Display the directory name in tabs?
set dirname_in_tabs false

# Enable the mouse support?
set mouse_enabled true

# Display the file size in the main column or status bar?
set display_size_in_main_column true
set display_size_in_status_bar true

# Display files tags in all columns or only in main column?
set display_tags_in_all_columns true

# Set a title for the window?
set update_title false

# Set the title to "ranger" in the tmux program?
set update_tmux_title false

# Shorten the title if it gets long?  The number defines how many
# directories are displayed at once, 0 turns off this feature.
set shorten_title 3

# Abbreviate $HOME with ~ in the titlebar (first line) of ranger?
set tilde_in_titlebar false

# How many directory-changes or console-commands should be kept in history?
set max_history_size 20
set max_console_history_size 50

# Try to keep so much space between the top/bottom border when scrolling:
set scroll_offset 8
# Flush the input after each key hit?  (Noticable when ranger lags)
set flushinput true

# Padding on the right when there's no preview?
# This allows you to click into the space to run the file.
set padding_right true

# Save bookmarks (used with mX and `X) instantly?
# This helps to synchronize bookmarks between multiple ranger
# instances but leads to *slight* performance loss.
# When false, bookmarks are saved when ranger is exited.
set autosave_bookmarks true

# You can display the "real" cumulative size of directories by using the
# command :get_cumulative_size or typing "dc".  The size is expensive to
# calculate and will not be updated automatically.  You can choose
# to update it automatically though by turning on this option:
set autoupdate_cumulative_size false

# Turning this on makes sense for screen readers:
set show_cursor false

# One of: size, natural, basename, atime, ctime, mtime, type, random
set sort natural

# Additional sorting options
set sort_reverse false
set sort_case_insensitive true
set sort_directories_first true
set sort_unicode false

# Enable this if key combinations with the Alt Key don't work for you.
# (Especially on xterm)
set xterm_alt_key false

# Whether to include bookmarks in cd command
set cd_bookmarks true

# Avoid previewing files larger than this size, in bytes.  Use a value of 0 to
# disable this feature.
set preview_max_size 0

# Add the highlighted file to the path in the titlebar
set show_selection_in_titlebar true

# The delay that ranger idly waits for user input, in milliseconds, with a
# resolution of 100ms.  Lower delay reduces lag between directory updates but
# increases CPU load.
set idle_delay 2000

# When the metadata manager module looks for metadata, should it only look for
# a ".metadata.json" file in the current directory, or do a deep search and
# check all directories above the current one as well?
set metadata_deep_search false

I was trying to find any solution online, but... couldn't find anything useful.
Learning is hard, but it's a fun :-P

Offline

#2 2015-10-01 15:26:40

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: i3 + Ranger - No file prewievs at all

Are you sure, you can't see a preview of a simple plain text file?
Elsewise, have you tried using the default configuration for ranger?

For the other filetypes, have you installed w3m, pdftotext et al.?

Offline

#3 2015-10-01 16:34:13

rjoukecu
Member
Registered: 2015-10-01
Posts: 5

Re: i3 + Ranger - No file prewievs at all

Yeah, I was even reinstalling (several times, hehe) ranger, xterm, w3m.....
I can still use mod + i to open previews in new window, but Ranger itself doesn't show a thing.

Offline

#4 2015-10-01 17:14:46

onslow77
Member
Registered: 2014-09-21
Posts: 279

Re: i3 + Ranger - No file prewievs at all

Hello!

Have you followed the ranger-wiki and copied all of the default configuration files?

Regards
Martin


It is advised to follow the How to post guide when posting on the Arch forum. If one consciously jumps over these elementary steps like reading the wiki and providing necessary information about the problem, one can be regarded as a Help Vampire.

Offline

#5 2015-10-02 05:12:43

rjoukecu
Member
Registered: 2015-10-01
Posts: 5

Re: i3 + Ranger - No file prewievs at all

onslow77 wrote:

Hello!

Have you followed the ranger-wiki and copied all of the default configuration files?

Regards
Martin

Hi, if you mean if I used this:

ranger --copy-config=all

, then yes.

When I compile those files, I get this message:

To stop ranger from loading both the default and your custom rc.conf,
please set the environment variable RANGER_LOAD_DEFAULT_RC to FALSE.

Can it be related to the problem? If so, I have no idea, what should I do with that.

Offline

Board footer

Powered by FluxBB