summaryrefslogblamecommitdiffstats
path: root/roles/obs/templates/mpv-track
blob: bb876777d7b613887627318a5b13744348511250 (plain) (tree)
1
2
3
4
5
6
7
8
9



                                                                      




                                          


                         


                                                                   
















                                                                                                               






                                                                                       
                
                                                                                                                                                                                                       
#!/bin/bash
# Run MPV with the output set to the right sink and with an IPC socket
# {{ ansible_managed }}

# Kill the background music if playing
if screen -list | grep -q background; then
    screen -S background -X quit
fi

# Update the overlay
FILE=$1
if [[ ! -f $FILE ]]; then
    LIST=(/data/emacsconf/assets/stream/emacsconf-2022-$FILE*.webm)
    FILE="${LIST[0]}"
    BY_SLUG=1
fi
shift
SLUG=$(echo "$FILE" | perl -ne 'if (/^emacsconf-[0-9]*-(.*?)--/) { print $1; } else { print; }')
if [[ -f /data/emacsconf/assets/overlays/$SLUG-other.png ]]; then
    echo "Found other overlay for $SLUG, copying"
    cp /data/emacsconf/assets/overlays/$SLUG-other.png ~/other.png
else
    echo "Could not find /data/emacsconf/assets/overlays/$SLUG-other.png, please override ~/other.png manually"
    cp /data/emacsconf/assets/overlays/blank-other.png ~/other.png
fi
if [[ -f /data/emacsconf/assets/overlays/$SLUG-video.png ]]; then
    echo "Found video overlay for $SLUG, copying"
    cp /data/emacsconf/assets/overlays/$SLUG-video.png ~/video.png
else
    echo "Could not find /data/emacsconf/assets/overlays/$SLUG-video.png, override ~/video.png manually"
    cp /data/emacsconf/assets/overlays/blank-video.png ~/video.png
fi
if [[ "x$BY_SLUG" == "x1" ]] && [[ -f /data/emacsconf/assets/intros/$SLUG.webm ]]; then
    INTRO=/data/emacsconf/assets/intros/$SLUG.webm
    echo "Found intro $INTRO"
else
    echo "Could not find /data/emacsconf/assets/intros/$SLUG.webm"
fi

# Play the video
DISPLAY="${DISPLAY:-:{{ item.vnc_id }}}" mpv --input-ipc-server={{ emacsconf_home }}/mpv-socket-{{ emacsconf_id }}-{{ item.id }} --audio-device=pulse/vid --profile={{ emacsconf_id }}-talks $FILE $* &