Ranger and graphics

I like running ranger. On Manjaro it came configured for displaying images right out of the box. In archlab it does nothing. After installing gimp it now uses this application to show an image but this a huge overkill. I would like to get some info about how to configure ranger to display images FAST. Which application and how to configure it in ranger. Points to info are also welcomed. I’m not lazy :wink:

I believe w3m (and possibly w3m-img) are the applications recommeded for file viewing. Sometimes w3m (text-based browser) is broken into separate packages - w3m, w3m-img (Debian and Void do it that way).

Then you have to configure it - there are some scripts ( /usr/share/docs/ranger I think) that need to be copied over to ~/.config/ranger.

The various helper applications like w3m, zathura for pdf etc … are defined in those scripts.

ranger file manager

ranger on Arch wiki

3 Likes

Yea on point @PackRat

Note that to display images, your terminal will need to support it.

I suggest getting to know ranger’s configs and make your own, copy the defaults with

ranger --copy-config=all

Now you’ll have ~/.config/ranger with a bunch of configs inside.

  • scope.sh handles a bunch of things to do with previews

  • rc.conf is where ranger’s settings are (think of it like a vimrc)

  • rifle.conf ranger’s file handler (what app opens when opening a file, picture, video, etc…)

To enable image previews, edit these lines in ~/.config/ranger/rc.conf

set preview_images true
set preview_images_method w3m
set use_preview_script true

With termite some issues can occur, either use urxvt or st or this is supposed to help

set draw_borders true

Voila, image previews

To change which applications are used to open things see rifle.conf

This is my rifle.conf, feel free to use whatever you like, the default is pretty well set up.
Also note: you can use r to pick from available options, by default rifle uses the first match.
I’d also highly suggest you read the comments in the default configs so you know what all of it means

mime ^text, label editor = $EDITOR -- "$@"
mime ^text, label pager = $PAGER -- "$@"
!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $PAGER -- "$@"

mime ^audio, terminal, has cmus = cmus add -Q "$@"
mime ^video, X, has mpv, flag f = mpv -- "$@"

mime ^image, X, has feh, flag f = feh --scale-down --keep-zoom-vp -B "#47515e" -- "$@"
mime ^image, X, has gimp, flag f = gimp -- "$@"
ext xcf, X, has gimp, flag f = gimp -- "$@"

ext x?html?, X, flag f = $BROWSER -- "$@"
ext x?html?, terminal = w3m "$@"

ext 1|5 = man "$1"
ext exe = wine "$1"
ext py = python -- "$1"
ext pl = perl -- "$1"
ext rb = ruby -- "$1"
ext js = node -- "$1"
ext sh = bash -- "$1"
ext php = php -- "$1"

ext iso, terminal, has flash = flash "$1"

ext pdf|djvu, has zathura, X, flag f = zathura -- "$@"

ext to|torrent, flag f, has deluge = deluge "$1"

ext 7z|ace|ar|arc|xar|xpi|xz|zip|gz,  has aunpack = aunpack -- "$@"
ext bz2?|cab|cpio|cpt|deb|dgc|dmg,    has aunpack = aunpack -- "$@"
ext iso|jar|msi|pkg|rar|shar|tar|tgz, has aunpack = aunpack -- "$@"

name ^[mM]akefile$ = make
name ^PKGBUILD$ = makepkg --printsrcinfo >.SRCINFO && makepkg -f --sign

label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $PAGER -- "$@"

mime application/x-executable = "$1"

Cheers

Thank you very much for this information. It will be very helpful. I need to change some things (I.e. I use another torrent program) but it’s all very informative. Thank you for your time!

To each their own but don’t get the graphics in Ranger deal. Kinda misses the point of the whole thing? Am I missing something here?

It’s not limited to images, so it’s kind of handy. You can get previews of pdf files, text files, images etc … from the file manager. Same principle as thumbnail previews in thunar.

2 Likes

I use Termite for the moment. I like the colors and the fonts. On Manjaro I used URxvt but on ArchLabs I have to reconfigure URxvt to match the fonts and colors of Termite. It’s on my to-do list. I have not found and easy and quick way to do this yet. I tried urxvt and the fonts are way smaller and the colors don’t match Termite. Any help to set this urxvt to the way Termite looks is welcome.

Spot on mate, I really don’t use previews for anything but text, people are far too hung up on something that really doesn’t matter, speed you up, or make anything even easier.

1 Like

I don’t use either, however you can set urxvt colours in ~/.Xresources

*foreground:  #494949
*background:  #E1E1E1
*cursorColor: #C0C0C0

*color0: #494949
*color1: #EF7878
*color2: #78a078
*color3: #CE9D00
*color4: #4E88CF
*color5: #AF86C8
*color6: #00AFAF
*color7: #C6C6C6

*color8:  #969896
*color9:  #EF7878
*color10: #59CC9C
*color11: #FFC266
*color12: #6699CC
*color13: #CC99CC
*color14: #4CBFBB
*color15: #C6C6C6

URxvt*background: [90]#2b303b
URxvt*scrollBar: false
URxvt*scrollBar_right: false
URxvt*internalBorder: 0
URxvt*externalBorder: 0
URxvt*letterSpace: -1
URxvt.font: xft:DejaVu Sana Mono:size=11
1 Like

Thank you for the .Xresource code. I will check it out tonight. You use neither? I guess you use st :slight_smile:

Anytime

Yes sir I use st, I really like the suckless community projects for a number of reasons

2 Likes