Random image slideshow every 5 seconds on Linux
user: what's the best way to perform an image slideshow in Linux to display random images from a directory every 5 seconds
assistant: For what you described on Ubuntu/Linux, **`feh` is probably the cleanest tool**: lightweight, fast, fullscreen-capable, and it directly supports both randomization and timed slideshows. Its current Ubuntu man page supports `--randomize`, `--slideshow-delay`, fullscreen, and recursive directory scanning.
Install it:
```bash
sudo apt install feh
```
Then, for a directory such as:
```text
/home/adam/Pictures/slideshow
```
run:
```bash
feh --fullscreen --randomize --slideshow-delay 5 /home/adam/Pictures/slideshow
```
Or the shorter equivalent:
```bash
feh -F -z -D 5 /home/adam/Pictures/slideshow
```
That gives you:
- **Fullscreen**
- **Random image order**
- **New image every 5 seconds**
- Automatically loops and **reshuffles when it reaches the end**
### If you have subdirectories too
Use:
```bash
feh -F -z -D 5 -r /home/adam/Pictures/slideshow
```
The `-r` option recursively includes images in folders underneath that directory.
### A version I think you'd like
I'd probably use:
```bash
feh \
--fullscreen \
--auto-zoom \
--randomize \
--slideshow-delay 5 \
--recursive \
/home/adam/Pictures/slideshow
```
`--auto-zoom` makes smaller images expand to better use the available screen instead of sitting tiny in the middle.
While it's running:
```text
Space / Right Arrow next image
Backspace / Left previous image
h pause/resume slideshow
f toggle fullscreen
z jump to random image
Esc / q exit
```
Those controls are built directly into `feh`.
**One other good option is `mpv`.** It has surprisingly good image-slideshow support and its current documentation says the default image-display duration is actually **5 seconds**. But for a simple random-photo display, **I'd choose `feh` over mpv** because its command-line options are purpose-built for exactly this.
If you're planning to put this on your **Stream Deck on the Ubuntu ROG Strix**, `feh` would also be ex…
user: that's works good. how about to randomly play videos from a directory?
assistant: For random videos, **`mpv` is the better tool**.
Install it if you don't already have it:
```bash
sudo apt install mpv
```
Then point it at the directory:
```bash
mpv --fullscreen --shuffle "/home/adam/Videos"
```
That will play the videos in **random order** and automatically move to the next one when each video ends. With `--shuffle`, mpv's current directory behavior is recursive by default, so it will also find videos inside subdirectories.
If you want it to **run forever**, reshuffling after it reaches the end:
```bash
mpv --fullscreen --shuffle --loop-playlist=inf "/home/adam/Videos"
```
That's probably the command I'd recommend for a continuous random-video display:
```bash
mpv \
--fullscreen \
--shuffle \
--loop-playlist=inf \
"/home/adam/Videos"
```
`--loop-playlist=inf` causes the playlist to restart indefinitely, and mpv reshuffles it again when looping.
Useful controls while it's playing:
```text
Space pause / resume
Right seek forward
Left seek backward
> next video
< previous video
f toggle fullscreen
m mute
9 / 0 volume down / up
q quit
```
### If you want only videos and no images/audio
Since mpv can also recognize images and audio when you give it an entire directory, you can explicitly tell it to load **video files only**:
```bash
mpv \
--fullscreen \
--shuffle \
--loop-playlist=inf \
--directory-filter-types=video \
"/home/adam/Videos"
```
That's the version I'd use for a dedicated **random video jukebox/screen saver**. The `--directory-filter-types=video` option restricts directory scanning to video media.
And if you'd like, we can make this even nicer on your Ubuntu machine—for example **hide the mouse cursor and on-screen controls, disable filenames/messages, and make it look like a seamless unattended video display**.
Showing first 4 of 4 messages. View the full conversation at https://mcwai.org/ai-conversation/random-image-slideshow-every-5-seconds-on-linux