#!/bin/bash

# very subtle easter egg, turn up the volume and wear headphones to get the best experience

if iconf -i nothomas && ! [ "$1" = "-f" ] ; then
    echo "this maneuver could've cost you 51 years and your ears"
    echo "be mindful of your spelling"
    exit 1
fi

if ! iconf thomassound; then
    if ! [ -e ~/instantos/thomas.mp3 ]; then
        pushd .
        cd ~/instantos/ || exit 1
        wget -q thomasthetankengine.surge.sh/thomas.mp3
        popd || echo "bruh"
    fi
fi

if pgrep mpv; then
    sl "$@"
    exit
fi

if iconf thomassound; then
    mpv "$(iconf THOMASSOUND)" &>/dev/null &
else
    mpv ~/instantos/thomas.mp3 &>/dev/null &
fi

command sl "$@"
pkill mpv
