#!/bin/sh

for ((i=1;i<=$#;i++));
do

    if [ ${!i} = "--getsavefilename" ]
    then ((i++))
	    filename=${!i};
    fi

    if [ ${!i} = "--version" ]
    then
            echo "someversion"
            exit
    fi

done;

path=$( echo ${filename%/*} )
file=$( echo ${filename##/*/} )

rm /tmp/lf-chrome-choosed
st -c lf -n lf -e $HOME/.local/bin/lf-ueberzug --selection-path=/tmp/lf-chrome-choosed
selected=$(cat /tmp/lf-chrome-choosed 2> /dev/null)
if [ ! $? = 0 ]
then
	exit 1
fi

if [ -d $selected ]
then
	echo "$selected$file"
else
	echo $selected
fi

