#!/bin/bash

basedir="/var/gdrive/slides"

killall fbi &> /dev/null

# get subdir from command line argument if given
if [ $# -eq 0 ]; then
    subdir="default"
else
    subdir=$1
fi

# combine to slide directory
slidedir="$basedir/$subdir"

# check if dir exists
if [ ! -d "$slidedir" ]; then
    echo "Error: could not find $slidedir"
    # fall back to default dir
    slidedir="$basedir/default"
fi

# run framebuffer image viewer on console 1 (-T 1)
fbi -noverbose -T 1 -a -t 7 -u `find $slidedir -iname "*.jpg"`