piframe/docs/slideshow.md

126 lines
3.7 KiB
Markdown
Raw Normal View History

# Slideshow
2020-08-03 01:05:29 +00:00
The below commands will setup ```fim``` as a slideshow on your display.
## Important Notes
2020-08-03 01:05:29 +00:00
* ```fim``` will crash if there are no photos for it to use as a slideshow
* You will likely want to tweak the ```fim``` command invocation below. These are great settings as a starting point but you'll probably want to make adjustments for your use case.
* This setup uses ```incron``` to restart ```fim``` when photos are deleted from the pictures folder. Without this piece ```fim``` will crash if a picture is removed from the pictures directory prior to ```fim``` rescaning the pictures directory.
## Setup
``` sh
2020-08-28 22:46:13 +00:00
# Setup UI binary
DL_URL=$(curl https://git.kemonine.info/api/v1/repos/PiFrame/piframe-go/releases | jq -r '.[0].assets[] | select(.name == "ui") | .browser_download_url')
wget $DL_URL -O /usr/local/bin/pf-ui
chmod a+x /usr/local/bin/pf-ui
# Setup systemd service for UI
mkdir /etc/systemd/system/getty@tty1.service.d/
cat > /etc/systemd/system/getty@tty1.service.d/override.conf <<EOF
[Service]
ExecStart=
ExecStart=-/usr/local/bin/pf-ui
StandardInput=tty
StandardOutput=tty
EOF
# Add fim user and setup fim
2020-08-03 01:05:29 +00:00
useradd -m -G video -s /usr/sbin/nologin fim
apt install acl
2020-08-03 18:01:45 +00:00
setfacl -m "u:fim:rwX" /tank/pictures
setfacl -dm "u:fim:rwX" /tank/pictures
2020-08-03 01:05:29 +00:00
apt install fim imagemagick ttf-dejavu
2020-08-28 22:46:13 +00:00
cat > /usr/local/etc/fimrc <<EOF
# Ensure simages are auto-centered on the screen
2020-08-06 20:59:42 +00:00
_want_autocenter=1;
# Reduce the amount of ram used by dialing back the image cache
_max_cached_images=1;
# Rotate screen if the display used (CONFU 5.5 in particular) isn't rotated proper
2020-08-28 22:46:13 +00:00
#_orientation=2;
# Turn on/off status bar and similar
_display_busy=0;
_display_console=0;
_display_status=0;
_display_status_bar=0;
_display_status_fmt=0;
EOF
2020-08-28 22:46:13 +00:00
cat > /etc/default/fim_albums <<EOF
2020-08-16 05:52:21 +00:00
/tank/pictures
EOF
2020-08-28 22:46:13 +00:00
cat > /usr/local/bin/pf-fim.sh <<EOF
#!/bin/bash
2020-08-28 22:46:13 +00:00
chvt 1
2020-08-03 07:03:35 +00:00
tput civis
2020-08-28 22:46:13 +00:00
exec </dev/tty1 >/dev/tty1 2>/dev/tty1
#echo 2 > /sys/class/graphics/fbcon/rotate_all
ALBUM_PATH=\`cat /etc/default/fim_albums\`
/usr/bin/fim --verbose --no-commandline --no-history --etc-fimrc /usr/local/etc/fimrc \
2020-08-03 07:03:35 +00:00
--device /dev/fb0 --vt 1 \
--execute-commands-early "clear" --final-commands "clear" \
--execute-commands 'while(1){display;sleep "300";next;}' \
--autozoom --random \
--cd-and-readdir --recursive \
2020-08-16 05:52:21 +00:00
"\$ALBUM_PATH"
EOF
2020-08-28 22:46:13 +00:00
chmod a+x /usr/local/bin/pf-fim.sh
cat > /etc/systemd/system/pf-ui.service <<EOF
2020-08-03 01:05:29 +00:00
[Unit]
2020-08-28 22:46:13 +00:00
Description=PiFrame UI
After=getty.target
2020-08-03 01:05:29 +00:00
[Service]
User=fim
2020-08-28 22:46:13 +00:00
ExecStart=/usr/local/bin/pf-ui
Restart=always
2020-08-03 01:05:29 +00:00
[Install]
WantedBy=multi-user.target
EOF
cat > /usr/local/bin/no-cursor-tty1.sh <<EOF
#!/bin/bash
/usr/bin/tput -T screen civis > /dev/tty1
EOF
chmod a+x /usr/local/bin/no-cursor-tty1.sh
cat > /etc/systemd/system/no-cursor-tty1.service <<EOF
[Unit]
Description=Disable tty1 cursor
After=getty.target
[Service]
User=root
ExecStart=/usr/local/bin/no-cursor-tty1.sh
[Install]
WantedBy=multi-user.target
EOF
DL_URL=$(curl https://git.kemonine.info/api/v1/repos/PiFrame/piframe-go/releases | jq -r '.[0].assets[] | select(.name == "inotify") | .browser_download_url')
wget $DL_URL -O /usr/local/bin/pf-inotify
chmod a+x /usr/local/bin/pf-inotify
cat > /etc/systemd/system/inotify-pictures.service <<EOF
[Unit]
Description=Watch for picture folder changes and restart slideshow
After=fim.service
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/pf-inotify
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
2020-08-03 01:05:29 +00:00
EOF
2020-08-28 22:46:13 +00:00
systemctl daemon-reload
2020-08-28 22:46:13 +00:00
systemctl enable --now no-cursor-tty1
systemctl enable getty@tty1.service
systemctl restart getty@tty1.service
systemctl enable --now inotify-pictures
```