Skip to content

Commit

Permalink
Implement PID and SSH checks, add autostart setup script. Remove opti…
Browse files Browse the repository at this point in the history
…on for running as systemd service as it does not work with VLC.
  • Loading branch information
eat-sleep-code committed Feb 27, 2024
1 parent 2a46e2b commit 39f9937
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 197 deletions.
27 changes: 3 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ tiny-tv-update # reinstalls Tiny TV program
+ _--loop_ : Set whether video plays continuously in a loop *(default: True)*
+ _--shuffle_ : Set whether category-based playback is shuffled *(default: False)*

---

### Playback Controls

You can control the device from a Bluetooth keyboard.

|Key|Action|
|---|---|
| - | Decrease volume <em> (in increments of 5%)</em> |
| + | Increase volume <em> (in increments of 5%)</em> |
| Space | Pause/Resume |
| q | Exit |
| Left | Restart current video |
| Right | Advanced to next video |



---

### Examples
Expand Down Expand Up @@ -134,15 +117,11 @@ defaults.pcm.card 1
## Autostart Tiny TV
Want to start the Tiny TV program every time you boot your Raspberry Pi? Here is how!

### Via *.profile* file
* Add a line to the very end of ~/.profile such as `tiny-tv 'category' --category 'cartoons'` and save the changes to the file.
* Restart the Tiny TV.
*Note that this method avoids many permissions issue which may arise when attemptint to use the **systemd** method below. However, it will attempt to start the Tiny TV program every time you login to via SSH, etc. You may need to press CTRL-C to abort the loading of the application in these instances.*

### Via systemd:
* Review `/etc/systemd/system/tiny-tv.service`
* Review the `AUTOSTARTCOMMAND` command in `~/tiny-tv/setup-autostart-tiny-tv.sh`
* If you would like to add any of aforementioned options you may do so by editing the service file.
* Run `~/tiny-tv/install-tiny-tv.service.sh`
* Run `~/tiny-tv/setup-autostart-tiny-tv.sh`
* Restart the Tiny TV.


> [!TIP]
Expand Down
12 changes: 0 additions & 12 deletions install-tiny-tv.service.sh

This file was deleted.

13 changes: 4 additions & 9 deletions install-tiny-tv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ sudo chown -R $USER:$USER /home/pi/tiny-tv-venv


echo -e '\033[93mInstalling Python libraries... \033[0m'
sudo /home/pi/tiny-tv-venv/bin/pip3 install pynput python-vlc yt-dlp rpi_backlight --force
sudo /home/pi/tiny-tv-venv/bin/pip3 install python-vlc yt-dlp rpi_backlight python-pidfile --force
echo 'SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"' | sudo tee -a /etc/udev/rules.d/backlight-permissions.rules


echo ''
echo -e '\033[93mProvisioning logs... \033[0m'
sudo mkdir -p /home/pi/logs
Expand All @@ -35,22 +36,16 @@ sudo mount -a
sudo chown -R $USER:$USER /home/pi/logs
sudo systemctl daemon-reload


echo ''
echo -e '\033[93mInstalling Tiny TV... \033[0m'
cd ~
sudo rm -Rf ~/tiny-tv
sudo git clone https://github.com/eat-sleep-code/tiny-tv
sudo chown -R $USER:$USER tiny-tv
cd tiny-tv
sudo chmod +x tiny-tv.py
sudo chmod +x backlight.py

echo ''
echo -e '\033[93mCreating Service... \033[0m'
sudo mv tiny-tv.service /etc/systemd/system/tiny-tv.service
sudo chown root:root /etc/systemd/system/tiny-tv.service
sudo chmod +x *.sh
echo 'Please see the README file for more information on configuring the service.'


cd ~
echo ''
Expand Down
13 changes: 13 additions & 0 deletions setup-autostart-tiny-tv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# This script will set Tiny TV to autostart when a local bash session starts.

AUTOSTARTCOMMAND=tiny-tv 'category' --category 'cartoons' --shuffle True --volume 0


# ==============================================================================
cd ~
echo ''
echo -e '\033[93mSetting up autostart... \033[0m'
sudo touch ~/.profile
sudo sed -i '/\b\(tiny-tv\)\b/d' ~/.profile
sudo sed -i "\$a$AUTOSTARTCOMMAND" ~/.profile
Loading

0 comments on commit 39f9937

Please sign in to comment.