IpPsar01
Posts: 5
Joined: Sat May 25, 2019 5:38 am

howto redirect input to feh (slideshow program)

Sat May 25, 2019 5:54 am

Hi,

Some help is needed on the following:

I would like to fork feh as a slideshow in the background and still be able to sent some keys to it (eg. 'n' for next picture or 'q' to quit).

So I created a pipe: mkfifo /tmp/cmdVideo
I exported DISPLAY=:0
and start: feh -Z -z -F -d -D10 -f /home/pi/newapp/AlleFotos </tmp/cmdVideo &


Via another shell I sent characters into the pipe:
To actually start feh: echo -n . > /tmp/cmdVideo
After that it starts showing pictures.

All my other characters don't arrive at feh. Eg.:
echo -n 'n' > /tmp/cmdVideo
echo -n 'q' > /tmp/cmdVideo
Feh just goes on showing pictures.

I have also tried to move the location of the '</tmp/cmdVideo' within the commandline but that did not help.
Obviously I am making a mistake here. Can someone help me in how to set this up correctly?

The same setup works fine for omxplayer .

Thanks in advance!

IpPsar01
Posts: 5
Joined: Sat May 25, 2019 5:38 am

Re: howto redirect input to feh (slideshow program)

Fri Jun 28, 2019 12:51 pm

Anyone perhaps able to direct me in the right direction?
Or is this forum not the right place?
All help / direction is appreciated.
Thanks in advance!

Andyroo
Posts: 4140
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: howto redirect input to feh (slideshow program)

Fri Jun 28, 2019 1:13 pm

There is a post here on using C to do it https://stackoverflow.com/questions/223 ... nd-program

If you do not want to code, then have a look at the screen command and using that as per here and here

I use TMUX rather than screen - I’m now going to have to see if it will do the same or not :lol:
Need Pi spray - these things are breeding in my house...

IpPsar01
Posts: 5
Joined: Sat May 25, 2019 5:38 am

Re: howto redirect input to feh (slideshow program)

Tue Jul 02, 2019 4:25 pm

Thanks a lot Andyroo.
This gives me a direction that is very useful.

IpPsar01
Posts: 5
Joined: Sat May 25, 2019 5:38 am

Re: howto redirect input to feh (slideshow program)

Thu Jul 04, 2019 8:32 pm

Thanks to the directions given... After a lot of trial and error I resolved it satisfactory enough.

The module that is called contains:
shellprog = subprocess.Popen(commando, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=1, preexec_fn=os.setsid)

Where commando is my: feh -Z -F -d -D40 -f /home/pi/newapp/fpl
the 'shellprog' is returned.

The calling module contains:
shellprg = fotoplayer.FotoPlayer()
time.sleep(5)
os.killpg(shellprg.pid, signal.SIGUSR1)
time.sleep(5)
os.killpg(shellprg.pid, signal.SIGUSR2)
time.sleep(5)
os.killpg(shellprg.pid, signal.SIGTERM)

I can not get feh to use the characters I sent in a pipe. It will only use the characters typed into the console keyboard if feh is havig the console focus.

All other methods I tried did not give the result I needed ( echo to /proc/XYZ/fd/0, use mkfifo pipe, ...)

Similar principle works better for omxplayer since omxplayer actually uses the characters I write into the pipe: shellprg.stdin.write("q")

Return to “Beginners”