{{Article summary text|feh is a lightweight and powerful image viewer that can also be used to manage the desktop wallpaper for standalone window managers lacking such features.}}

+

{{Article summary heading|Related}}

+

{{Article summary wiki|Nitrogen}}

+

{{Article summary wiki|sxiv}}

+

{{Article summary end}}

[https://derf.homelinux.org/~derf/projects/feh/ feh] is a lightweight and powerful image viewer that can also be used to manage the desktop wallpaper for standalone window managers lacking such features.

[https://derf.homelinux.org/~derf/projects/feh/ feh] is a lightweight and powerful image viewer that can also be used to manage the desktop wallpaper for standalone window managers lacking such features.

==Installation==

==Installation==

−

{{pkg|feh}} is available in the [[Official Repositories|official repositories]].

+

[[pacman|Install]] {{pkg|feh}}, which is available in the [[Official Repositories|official repositories]].

==Usage==

==Usage==

Line 19:

Line 25:

* The {{Ic|-g}} flag forces the images to appear no larger than 640x480

* The {{Ic|-g}} flag forces the images to appear no larger than 640x480

+

* The {{Ic|-d}} flag draws the file name

* The {{Ic|-S filename}} flag sorts the images by file name

* The {{Ic|-S filename}} flag sorts the images by file name

Line 24:

Line 31:

====File Browser Image Launcher====

====File Browser Image Launcher====

−

The following script, originally posted [https://bbs.archlinux.org/viewtopic.php?pid=884635#p884635 on the forum], is useful for file browsers. It will display your selected image in feh, but it will enable you to browse all other images in the directory as well, in their default order, i.e. as if you had run "feh *" and cycled through to the selected image.

+

The following script is useful for file browsers. It will display your selected image in feh, but it will enable you to browse all other images in the directory as well, in their default order, i.e. as if you had run "feh *" and cycled through to the selected image.

The script assumes the first argument is the filename.

The script assumes the first argument is the filename.

−

{{bc|<nowiki>

+

{{hc|feh_browser.sh|<nowiki>

#!/bin/bash

#!/bin/bash

Line 55:

Line 62:

Invoke the script with the selected image's path, followed by any additional arguments to feh. Here is an example of a launcher that you can use in a file browser:

Invoke the script with the selected image's path, followed by any additional arguments to feh. Here is an example of a launcher that you can use in a file browser:

−

/path/to/script %f -F -Z

+

{{bc|$ /path/to/script/feh_browser.sh %f -F -Z}}

{{Ic|-F}} and {{Ic|-Z}} are feh arguments. {{Ic|-F}} opens the image in fullscreen mode, and {{Ic|-Z}} automatically zooms the image. Adding the {{Ic|-q}} flag (quiet) suppresses error messages to the terminal when feh tries loading non-image files from the current folder.

{{Ic|-F}} and {{Ic|-Z}} are feh arguments. {{Ic|-F}} opens the image in fullscreen mode, and {{Ic|-Z}} automatically zooms the image. Adding the {{Ic|-q}} flag (quiet) suppresses error messages to the terminal when feh tries loading non-image files from the current folder.

+

+

A simple but less versatile alternative is

+

{{hc|feh_browser.sh|<nowiki>

+

#! /bin/sh

+

feh -. "$(dirname "$1")" --start-at "$1"

+

</nowiki>}}

+

This one does not seem to accept options.

===As a desktop wallpaper manager===

===As a desktop wallpaper manager===

Line 64:

Line 78:

When using [[GNOME]], you must disable Nautilus from controlling the desktop. The easiest way is to run this command:

When using [[GNOME]], you must disable Nautilus from controlling the desktop. The easiest way is to run this command:

The following command is an example of how to set the initial background:

The following command is an example of how to set the initial background:

−

$ feh --bg-scale /path/to/image.file

+

{{bc|$ feh --bg-scale /path/to/image.file}}

Other scaling options include:

Other scaling options include:

−

--bg-tile FILE

+

{{bc|

−

--bg-center FILE

+

--bg-tile FILE

−

--bg-max FILE

+

--bg-center FILE

−

--bg-fill FILE

+

--bg-max FILE

+

--bg-fill FILE

+

}}

−

To restore the background on the next session, add the following to your startup file (e.g. {{ic|~/.xinitrc}}, {{ic|~/.config/openbox/autostart.sh}}, etc.):

+

To restore the background on the next session, add the following to your startup file (e.g. {{ic|~/.xinitrc}}, {{ic|~/.config/openbox/autostart}}, etc.):

−

sh ~/.fehbg &

+

{{bc|$ sh ~/.fehbg &}}

To change the background image, edit the file {{ic|~/.fehbg}} which gets created after running the command {{Ic|feh --bg-scale /path/to/image.file}} mentioned above.

To change the background image, edit the file {{ic|~/.fehbg}} which gets created after running the command {{Ic|feh --bg-scale /path/to/image.file}} mentioned above.

+

== Tips and tricks ==

+

===Random background image===

+

==== Using a script ====

+

To rotate the wallpaper randomly, create a script with the code below (e.g. {{ic|wallpaper.sh}}). Make the script executable:

−

====Random background image====

+

{{bc|$ chmod +x wallpaper.sh}}

−

To rotate the wallpaper randomly, create a script with the code below (e.g. {{ic|wallpaper.sh}}). Make the script executable ({{Ic|chmod +x wallpaper.sh}}) and call it from {{ic|~/.xinitrc}}. You can also put the source directly in {{ic|~/.xinitrc}} instead of in a separate file.

+

+

and call it from {{ic|~/.xinitrc}}. You can also put the source directly in {{ic|~/.xinitrc}} instead of in a separate file.

Change the {{ic|~/.wallpaper}} directory to fit your setup and the {{Ic|15m}} delay as you please (see {{Ic|man sleep}} for options).

Change the {{ic|~/.wallpaper}} directory to fit your setup and the {{Ic|15m}} delay as you please (see {{Ic|man sleep}} for options).

−

{{bc|<nowiki>

+

{{hc|wallpaper.sh|<nowiki>

#!/bin/sh

#!/bin/sh

Line 98:

Line 119:

This version does not fork as much, but this version does not recurse through directories:

This version does not fork as much, but this version does not recurse through directories:

−

{{bc|1=

+

{{hc|wallpaper.sh|<nowiki>

#!/bin/bash

#!/bin/bash

shopt -s nullglob

shopt -s nullglob

−

cd ~/.wallpaper

cd ~/.wallpaper

Line 108:

Line 128:

files=()

files=()

for i in *.jpg *.png; do

for i in *.jpg *.png; do

−

<nowiki>[[ -f $i ]]</nowiki> && files+=("$i")

+

[[ -f $i ]] && files+=("$i")

done

done

range=${#files[@]}

range=${#files[@]}

Line 116:

Line 136:

sleep 15m

sleep 15m

done

done

+

</nowiki>}}

+

+

=====For dual screen no-xinerama =====

+

This script replace the call to '''feh''' for add a wallpaper on systems with dual screen nvidia twinview (for example).

+

{{hc|wallpaper.sh|<nowiki>

+

#!/bin/sh

+

exec feh --bg-max --no-xinerama "$@"

+

</nowiki>}}

+

+

==== Using a cron job ====

+

Using a [[cron]] job, you can get a similar result, and it does not require having a script constantly sleeping.

+

+

Just do {{ic|$ crontab -e}} and add:

+

+

{{bc|<nowiki>

+

* * * * * DISPLAY=:0.0 feh --bg-max "$(find ~/.wallpaper/|shuf -n1)"

+

</nowiki>}}

+

+

==== Using systemd user session ====

+

{{Note|This is useful '''only''' if you are using ''systemd user session''. Read [[Systemd/User]] for more details.}}

Installation

Usage

feh is highly configurable. For a full list of options, run feh --help.

As an image viewer

To quickly browse images in a specific directory, you can launch feh with the following arguments:

$ feh -g 640x480 -d -S filename /path/to/directory

The -g flag forces the images to appear no larger than 640x480

The -d flag draws the file name

The -S filename flag sorts the images by file name

This is just one example; there are many more options available should you desire more flexibility.

File Browser Image Launcher

The following script is useful for file browsers. It will display your selected image in feh, but it will enable you to browse all other images in the directory as well, in their default order, i.e. as if you had run "feh *" and cycled through to the selected image.

Invoke the script with the selected image's path, followed by any additional arguments to feh. Here is an example of a launcher that you can use in a file browser:

$ /path/to/script/feh_browser.sh %f -F -Z

-F and -Z are feh arguments. -F opens the image in fullscreen mode, and -Z automatically zooms the image. Adding the -q flag (quiet) suppresses error messages to the terminal when feh tries loading non-image files from the current folder.

A simple but less versatile alternative is

feh_browser.sh

#! /bin/sh
feh -. "$(dirname "$1")" --start-at "$1"

This one does not seem to accept options.

As a desktop wallpaper manager

feh can be used to manage the desktop wallpaper for window managers that lack desktop features, such as Openbox, Fluxbox, and xmonad.

When using GNOME, you must disable Nautilus from controlling the desktop. The easiest way is to run this command: