1

I've been looking for a tool that either works or can be customized for the following task.

My end goal is to use the terminal to open, and navigate through some folder containing pictures. The behavior I'm looking for is similar to mplayer, where the user can submit input via the terminal to the display window.

More specifically, I'd like to pass in /home/parrot/Pictures/* as an argument to some CLI program. The program opens the first photo and awaits input, using some key ( presumably arrow key) the program tells the display window to get the next photo.

I've looked into and also been recommended to feh, but the program doesn't appear to solve this issue. While it does run in the background I attempted and failed at getting the next photo through a series of random key pressing. I also looked into its action key functionality but those only apply to its displayed window and not the terminal.

Has anyone already figured out such a set up? Have my google search skills failed me?

TLDR

  1. Open picture1.png in some image viewer at the terminal
  2. Press arrow key -in the terminal-
  3. Picture2.png is now displayed in the image viewer
1

2 Answers 2

0

Try mvi, a modification of mpv to view images. Manual install:

  1. Make sure mpv is installed, (e.g. sudo apt install mpv).
  2. Then, if there's no ~/.config/mpv directory, make one: mkdir ~/.config/mpv
  3. Download the archive containing the three files required for mvi, (image.lua, input-image.conf, and mpv.conf): wget https://gist.github.com/haasn/7919afd765e308fa91cbe19a64631d0f/archive/5dd2e4351fe24815b8d3ca5719ed276ed3aba5df.zip and unpack it into the ~/.config/mpv directory.
  4. From the command prompt:

    alias mvi='mpv -profile image'
    

Assuming ~/Pictures isn't empty, run mvi ~/Pictures/*.

0

I figured out a jimmy-rigged solution to the original problem.

The script below will solve the problem using eog. The current issue is that it's unstable, crashing if you fly through the images too quickly. Depending on your terminal/window manager you may need to tweak some settings to keep focus in your terminal when a window launches.

The script is currently setup to filter png images, anyone looking to use this may need to alter to jpeg or extend the script to handle multiple file extensions.

I'm still hoping for a better solution, I thought sharing my progress may help.
-shadyP

Steps

In your first terminal eog /home/parrot/Pictures/
In your second terminal ./picScript.sh /home/parrot/Pictures/

#!/bin/bash
i=0
index[$i]= "temp"
echo "~~script unstable, use at own risk~~" 
echo "due to lazy design eog must already be running from another terminal, failure to do so will cause this program to deadlock waiting for eog to return\n "
echo "Press k to go to next"
echo "Press j to go to previous"
echo "ctrl + c to quit"
IFS=$'\n'
for filename in $1*.png; do
    index[$i]=$filename
    i=$((i+1))
done
i=0

eog -w ${index[$i]}
while true; do

    read  -n 1 input
    if [ "$input" = "j" ] && [ $i != 0 ] ;then

        i=$((i- 1))
        eog -w ${index[$i]}
    elif [ "$input" = "k" ] && [ $i !=  "${#index[@]}"  ] ; then
        i=$((i+1))
        eog -w ${index[$i]}  
    fi
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.