Friday, August 7, 2015

I want to display a picture on the screen for at most 30 seconds.  If the user presses a button, the picture should no longer be displayed and the program should move on to the next step.

There are several options to do this.
  1. Display a picture in a gui user interface like xwindows
  2. Display the picture on a smaller monitor but use an LED screen as the user interface.
  3. Display a picture as part of another document from the command prompt
  4. Display a picture from the command prompt
I played around with some of the options.  Here are my notes from working on this.  They are not well organized.

Display a picture as part of another document from the command prompt
Need to make a PDF file.
Display a PDF file.
Close the PDF file on demand.

The Python Imaging Library or PIL might work.  It will display an image but it looks like it uses the computer's default image display program.  Might only work in windows.

Display a picture from the command prompt.
Some people said you could use fbi in another tty session.  fbi does have an option -T to display the image in a different tty.  That does work but it enters the commands at the current prompt on that session.

I can use fbi -t 5 -1 -a -T 2 <image.jpg> to display an image on the second tty and then exit.

Starting the fbi process does not make fbi the "session leader".  The shell is the session leader.  fbi is the process group leader for a process group containing only itself.  See this page for more details.

I started the fbi process on tty1. Then, went to tty2 and killed the process in tty1.  That worked.

I started the fbi process on tty1.  Then, killed it from a ssh session on my laptop.  That worked.  So, if I can just find the session number of the fbi session, I should be able to kill it.

Tried running this command to kill the fbi session:

ps axf | grep <process name> | grep -v grep | awk '{print "kill -9 " $1}' | sh

It locked up the tty sessions.  I could still access the pi using ssh but not with the keyboard.  Had to cycle power on the pi.

After rebooting, did the same thing several more times.  It worked every time.  Not sure what this means.

The psutil code has a function that will get a list of all the processes and put them in a dictionary.  I can use that function to find the process running fbi.  However, fbi just seems to mess up the process when it is kicked off from python.

Tried eog.  It only works with x windows.  Same with evince.

It looks like PDF files can only be viewed in x windows.

Maybe the tty idea will work without killing the process.  The idea would be to display the image in tty2 but switch back to tty1 when the user presses a button.

Googling this topic makes it look too complicated.