Skip to content

Commit

Permalink
Auto-import script + doc
Browse files Browse the repository at this point in the history
  • Loading branch information
theo-chassaigne committed Sep 16, 2016
1 parent 34f335a commit ed5e041
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 26 deletions.
29 changes: 29 additions & 0 deletions doc/2-PI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@ To be able to play the songs correctly, ALSA needs a bit of configuration. To do

defaults.ctl.!card 1;

Auto-load .song files from a USB key
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

WARNING: You first need to clone the server's repository on the Pi an open its folder (see ``3-COMPILING.rst`` for details about the procedure).

First, open the ``share/import_music.sh`` to setup the copy script. You can change the following variables:

``extension``
Extension of the song files. Default: ``"song"``.

``destination``
Folder where to copy the files. Default: ``"/home/pi/songs"``.

``user``
Name of the user that owns the ``destination`` folder. Default: ``"pi"``.

``led``
LED's ``wiringpi`` GPIO identifier (to signal the script is running). Default: ``"5"``

Once it's done (you can also leave the default values), copy the script to ``/usr/local/bin``, and the ``udev`` rule file to ``/etc/udev/rules.d``::

# cp share/import_music.sh /usr/local/bin/
# cp share/89-usbcopy.rules /etc/udev/rules.d/

The system should automatically detect the new rule, and will automatically copy the .song (or whatever you want) files from a USB key/drive to the folder you choosed.
Note that a LED should be activated during the whole operation, so don't touch the key or drive during that time.



Wifi bridge setup
-----------------

Expand Down
1 change: 1 addition & 0 deletions share/89-usbcopy.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KERNEL=="sd[a-z]?", SUBSYSTEM=="block", ACTION=="add", RUN+="/usr/local/bin/import_music.sh %k"
1 change: 0 additions & 1 deletion share/98-usbcopy.rules

This file was deleted.

32 changes: 32 additions & 0 deletions share/import_music.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

######
# Copy the $extension files from the root folder (/)
# of a USB key to the $destination folder
#
# $1 : Device's kernel name
######

extension="song"
destination="/home/pi/songs"
user="pi"
led="5"

gpio mode $led out
gpio write $led 1

mkdir /media/song_$1

mount /dev/$1 /media/song_$1

echo "mounted" >> /home/pi/truc.txt

cp -n /media/song_$1/*.$extension $destination
sudo chown -R $user $destination
sync

umount /media/song_$1
rmdir /media/song_$1

gpio write $led 0

25 changes: 0 additions & 25 deletions share/musique.sh

This file was deleted.

0 comments on commit ed5e041

Please sign in to comment.