Using feh as the default image viewer/browser in a Tiling WM environment

I bought a new miniPC and use it as a HTPC with a nice Debian Installation and AwesomeWM.  Since everything on this system should be a bit lightweight i thought about trying feh (wich was already installed) as the default image viewer … and i have to say that it’s surprisingly nice. Who needs an user interface just for some back/forward/zoom buttons anyway? Just use the cursor keys for that.

Config files

feh comes with many command line options (just enter man feh) and it needs a lot of them to really look nice. So it makes sense to make a feh config-file (which basically is just a list of command line arguments which will get loaded by default). The global config files would be in /etc/feh and the user config files in ~/.config/feh. There are three possible config files, one is called ‚themes‘ (it is the file for default command line arguments), one is called ‚keys‘ for key bindings and one is called ‚buttons‘ for mouse button bindings.
Here is the config files i use:

~/.config/feh/themes
feh -B black \
-d \
-N \
--geometry 500x500 \
--auto-zoom

‚-b Black‘ means that the background is black (and not those ugly tiles), ‚-d‘ means that it draws the filename in the upper left corner, ‚-N‘ means that there is no right-click-menu.
‚–geometry 500×500‘ and ‚–auto-zoom‘ are actually very important for the use in Tiling WMs. Without those options, the zooming levels would get messed up every time when you change the size of the windows.

~/.config/feh/keys
save_filelist
toggle_fullscreen f

This config-file removes the strange behaviour of feh to save a filelist when you press F and binds it to toggle fullscreen instead. I am used to mpv and mplayer, so i expect F to be the button for fullscreen.

Create a script, so that you are always able to browse through all images in a directory

Currently, when you open a image with ‚feh filename.png‘, it would open just this one image and you would not be able browse through the whole directory. If you just execute ‚feh‘ in a directory, you will be able to browse through all images, but it starts with some random first one.
If you use ‚feh –start-at ./filename.png .‚ it would be the behaviour i want, but it’s a bit uncomfortable to type. So lets create a script in /usr/local/bin:

 /usr/local/bin/fehl
#!/bin/sh
#If no argument is given, just start feh
if [ -z ${1} ]; then
feh
exit
fi

#Set different seperator to avoid problems with spaces
IFS='
'

FPATH="$1"
FNAME="$(basename "$FPATH")"
DPATH="$(dirname "$FPATH")"
#If just filename and no path is given, assume that it's in current directory
if [ $DPATH=="" ]; then
DPATH="."
FPATH="./$FNAME"
fi
echo "DPATH = $DPATH"
feh --start-at $FPATH $DPATH

Make it executeable with ‚chmod +x /usr/local/bin/fehl‘ and now the command to open an image would be ‚fehl filename.png‘.

Make it your default image viewer in Thunar

To make it your default image viewer in Thunar, you would just right-click an image, chose „Open With“/“Open with other Application“, enter „fehl“ in the „Use a custom command“ field, check the „Use as default for this kind of file“ box and click Open.