RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    FBI Image Viewer display image on Pi shutdown

    Scheduled Pinned Locked Moved Help and Support
    pi shutdownfbitipsandtricksimageviewer
    20 Posts 8 Posters 6.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • obsidianspiderO
      obsidianspider @**Scannigan**
      last edited by

      @__Scannigan__ said in FBI Image Viewer display image on Pi shutdown:

      I don't have /etc/rc.local.shutdown

      You'd have to create it. sudo nano r/etc/rc.local.shutdown should open nano with nothing in it. When you save, it'd create the file. What should go in that file? Well, whatever commands you'd like the system to run when you shut the system down. (Whatever you'd type in at the terminal.)

      šŸ“· @obsidianspider

      * 1 Reply Last reply Reply Quote 0
      • *
        **Scannigan** @obsidianspider
        last edited by

        @obsidianspider Excuse my ignorance, so is the rc.local basically a start up one and rc.local.shutdown would be a shut down one?

        So let say I needed to create two script one for sound and one for an image I would need to create two .sh scripts then point to them in rc.local.shutdown?

        obsidianspiderO 1 Reply Last reply Reply Quote 0
        • obsidianspiderO
          obsidianspider @**Scannigan**
          last edited by

          @__Scannigan__ I don't know a ton about it either, but I know that rc.local will run those commands when you boot, so I'm assuming rc.local.shutdown will run it when it's shutting down? I've not personally messed with the latter, but rc.local is what starts my Mausberry monitoring script.

          I would think that you could write one bash script that essentially runs both commands, and then put that in the rc.local.shutdown. Obviously test the script while the Pi is running first before trying to automate it. I would think that the worst case scenario is that creating that file just ends up doing nothing at all. I don't think you'll break the Pi or your OS.

          šŸ“· @obsidianspider

          * 1 Reply Last reply Reply Quote 1
          • *
            **Scannigan** @obsidianspider
            last edited by

            @obsidianspider Cheers bud I'll see if I can make any progress, worst thing that can happen is the script just won#t work

            CapemanC 1 Reply Last reply Reply Quote 0
            • CapemanC
              Capeman @**Scannigan**
              last edited by Capeman

              @__Scannigan__ Not sure if you got this working yet, but I was interested so i read into it a bit. This is the synopsis of what i've come up with, step by step for any noobs reading (i'm a bit of one myself).

              Step 1 would be to install FBI from the command line:

              sudo apt-get install fbi

              This is the call you would use to run it if you wanted to do it on command:

              fbi -d /dev/fb0 -a *.jpg

              The -d /dev/fb0 variable defines the framebuffer device
              The -a defines autozoom
              And obviously *.jpg would be renamed to the path of your jpeg file

              Now (i think) all you would need to do is create this file which is called on shutdown by default as was mentioned above:

              /etc/rc.local.shutdown

              And write a simple bash script inside it containing the run command above:

              #! /bin/bash
              #-a enables autozoom
              #name jpg to match your file
              #timeout -t sec / might change duration on screen
              fbi -d /dev/fb0 -a -t 20 image.jpg

              Anyone smarter than me want to chime in to let me know if this seems correct? I'll test it tonight and write back.

              Vector Artist, Designer and Maker of Stuff: Laser Cut Atari / Pixel Theme Bartop

              * 1 Reply Last reply Reply Quote 1
              • *
                **Scannigan** @Capeman
                last edited by

                @Capeman won't be able to try it into Monday, you'll never to let me know how it goes

                1 Reply Last reply Reply Quote 0
                • S
                  sinibomb
                  last edited by

                  Bit of a thread necro, but wondering if anyone has got this to work?

                  I've created /etc/rc.local.shutdown, written the bash script per @Capeman, but nothing seems to happen when I shutdown via Emulationstation.

                  I'm very much a noob in terms of any coding, so not sure what (if any) steps I've missed.

                  * 1 Reply Last reply Reply Quote 0
                  • *
                    **Scannigan** @sinibomb
                    last edited by

                    @sinibomb I actually got something working, I'm out at the moment when I'm back at my Pi I'll send you what I added

                    1 Reply Last reply Reply Quote 0
                    • S
                      sinibomb
                      last edited by

                      @Scannigan Brilliant, many thanks

                      * 1 Reply Last reply Reply Quote 0
                      • *
                        **Scannigan** @sinibomb
                        last edited by

                        @sinibomb

                        This was just a simple change to the popular shutdown button script

                        But this played two audio files and displays an image on Shutdown, change .wav and .PNG file names to suit

                        shutdown.py

                        #!/usr/bin/python import RPi.GPIO as GPIO import time import subprocess # we will use the pin numbering to match the pins on the Pi, instead of the # GPIO pin outs (makes it easier to keep track of things) GPIO.setmode(GPIO.BOARD) # use the same pin that is used for the reset button (one button to rule them all!) GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP) oldButtonState1 = True while True: #grab the current button state buttonState1 = GPIO.input(5) # check to see if button has been pushed if buttonState1 != oldButtonState1 and buttonState1 == False: # start playing silence to keep audio channel open to prevent missing beginning audio myinput = open('/dev/zero') subprocess.Popen(['/usr/bin/aplay', '-c2', '-r48000', '-fS16_LE', '-N' ], stdin=myinput ) # start showing screen (underneath emulationstation) subprocess.call("/home/pi/scripts/showImg.sh", shell=True) time.sleep(1) # play audio 1
                        subprocess.call("/usr/bin/aplay /home/pi/scripts/audio_1.wav", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) time.sleep(2) # quit emulation station subprocess.call("killall -SIGQUIT emulationstation", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) time.sleep(1) # play audio 2 subprocess.call("/usr/bin/aplay /home/pi/scripts/audio_2.wav", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) time.sleep(3) # shutdown subprocess.call("shutdown -h now", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) oldButtonState1 = buttonState1 time.sleep(.5)

                        showImg.sh

                        #!/bin/sh sudo /usr/bin/fbi -T 2 -once -t 30 -noverbose -a "/home/pi/scripts/image.png" &

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                        Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.