I have the slideshow application ‘feh’ running in the foreground on the console screen.
The idea is that feh is controlled by a another program (python) running.
This python program reads keyboard input but also processes the return string from eg. Google speech-to-text. As such it instructs feh to move to the next/previous picture (via signal.SIGUSR1), stop feh (signal.SIGTERM) and start a video (using omxplayer), etc..
However… since feh is running on the foreground feh takes the input from the keyboard!
So when the 'a' is pressed on the keyboard I want to close feh and start the default radio channel using omxplayer. Or when the 'v' is pressed i want to start a default video using omxplayer. But feh is catching the keystrokes so nothing happens
It of course works when the shell in which the python program is running is on the foreground having focus.
How can I redirect the console keyboard/keystrokes to my python program and still have feh run in the foreground?
When playing videos (using omxplayer) my python program does get the keystrokes and all works fine.
BTW: the python program is not started in the background using ‘&’. It is the python program that forks feh using:
commando = "feh -Z -F -d -D30 -f " + config.FotoPlaylist
shellprog = subprocess.Popen(commando, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=1, preexec_fn=os.setsid)
When I run a ps -ax | grep feh I get two entries (probably due to the 'shell=true'):
1084 ? Ss 0:00 /bin/sh -c feh -Z -F -d -D30 -f /tmp/FehPlaylist
1085 ? S 0:57 feh -Z -F -d -D30 -f /tmp/FehPlaylist
Thsese processes also do not have a TTY assigned. Would that somehow cause this problem?
(changing to call to 'shell=false' gives an error so that is not an option)
Peculiar is that the same command is used to start omxplayer for internet radio and that is linked to a shell:
commando = "omxplayer -b -o local \"%s\"" % audiobestand
shellprog = subprocess.Popen(commando, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,bufsize=0)
'ps -ax | grep omx' gives:
1064 pts/0 S+ 0:00 /bin/sh -c omxplayer -o local http://playerservices.streamtheworld.co ... DIOAAC.aac
1065 pts/0 S+ 0:00 /bin/bash /usr/bin/omxplayer -o local http://playerservices.streamtheworld.co ... DIOAAC.aac
1076 pts/0 Sl+ 1:56 /usr/bin/omxplayer.bin -o local http://playerservices.streamtheworld.co ... DIOAAC.aac
Thanks for any help!