Select Page

ABIOLA RASP – Raspberries for African School Projects

Wie können wir helfen?

< Alle Themen
Print

Start SlideShow automatically

no-261 au-03

Slideshow

A Slideshow is a presentation of a series of still images on a projection screen or electronic display device typically in a prearranged sequence. In this article, a slideshow will start when you insert your USB Stick.

Install needed programs

You must install two programs firstly.

1) Install pyudev

pip install pyudev

2) Install feh

sudo apt-get install feh

Create a Python Script

We’ll create a Python Script. Please follow below instructions.

1) Run below command to be sure current directory

pwd

2) Your current directory should be /home/pi

3) Create Slideshow.py script

touch Slideshow.py

Edit the script

We’ll write our Pyhton code into Slideshow.py

1) Open the script with Gedit text editor.

gedit Slideshow.py

You can use another text editor.

1) Write below code into script.

!/usr/bin/env python
import pyudev
import os
import time

context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem=’usb’)

for device in iter(monitor.poll, None):
if device.action == ‘add’:
print(‘{} connected’.format(device))
time.sleep(5)
os.system(‘feh \
–recursive \
–fullscreen \
–quiet \
–hide-pointer \
–slideshow-delay 3 \
/media/pi/SANDISK/slideshow’)

WARNING!
Please DO NOT copy the code. The best way is to write step by step according to the screenshot.

2) Click Save and wait.

3) Close the file

1) Change the permission of Slideshow.py

chmod 777 Slideshow.py

Edit LXDE autostart file

You have to edit the autostart file and add the script here.

1) Open autostart file with Gedit editor.

sudo gedit /etc/xdg/lxsession/LXDE-pi/autostart

1) Add below line

@lxterminal -e “/home/pi/Slideshow.py”

2) Click Save button and wait.

3) Close the file

Copy images into USB Stick

Now, we’ll prepare our USB Stick for the slideshow.

1) Plugin your USB Stick to Raspberry Pi

2) Create folder (We created slideshow folder)

1) Copy your images that you want to use for slideshow into your folder.

2) Here is the current directory. We’ll use it next section.

Modify the Python Script

You must modify the script according to your USB Stick name and folder.

1) Open Slideshow.py with Gedit editor.

gedit Slideshow.py

1) Copy the directory where your images are located.

2) Change this line with your directory.

3) You can set the slideshow time changing this value. We set it 3 seconds.

Remove your USB Stick and reboot Raspberry Pi.

The terminal will open after reboot. Please do not close it.

Plugin your USB Stick and the slideshow will start after 5 seconds.

You can stop the Slideshow using Esc button.

If you close the terminal, the slideshow won’t start after instert the USB Stick. In this situation you must remove your USB Stick and reboot Rasberry Pi.

Zurück How to give a permission?
Weiter mount command
Inhaltsverzeichnis