mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

148 lines
4.4 KiB

#!/bin/bash
usage_create_lvpxml() {
echo -n
}
create_thumbnail() {
tmp="`mktemp`"
rm -f $tmp
file="$1"
item=$2
time=$3
mplayer -nosound -vo png -ss $time -frames 2 "livesystem/$file" >/dev/null 2>&1
orig="00000002.png"
[ ! -f "${orig}" ] && orig="00000001.png"
[ ! -f "${orig}" ] && return 1
convert -resize '128x128!' ${orig} SGI:$tmp
convert -depth 8 -size 128x128 SGI:$tmp gray:$tmp.tmp
convert -depth 8 -size 128x128 gray:$tmp.tmp SGI:$tmp.gray
mv $tmp $item.color.rgb
mv $tmp.gray $item.gray.rgb
rm -f $tmp*
rm -f 000*
return 0
}
process_create_lvpxml() {
unset files
unset title
unset titleold
time="00:02:00"
offset=0
for x in ${!file_*} ; do
[ -z "${files}" ] || files="${files}\n"
files="${files}${x}" # note: we're not dereferencing the variables here to keep the order the user specified
done
files=`echo -e ${files} | sort`
rm -f ${lvpxml}
touch ${lvpxml}
echo "Creating lvp.xml file"
echo "<lvp>" >${lvpxml}
item=0
for file in ${files} ; do
eval "file=\${${file}}" # dereference the variable to get the real file
title=${file##*/}
title=${title%% -*}
if [ "${title}" != "${titleold}" ] ; then
titleold=${title}
echo "Found possible new title \"${title}\""
confirm "Do you want to start a new headline?"
if [ ${?} -eq 0 ] ; then
[ ${offset} -gt 0 ] && offset=$(( ${offset} + 2 ))
[ $(( ${item} % 4 )) -gt 0 ] && item=$(( ${item} + ( 4 - ( ${item} % 4 ) ) ))
lvp_read tmp "${title}" Please enter new title [${title}]:
[ -z "${tmp}" ] || title="${tmp}"
cat >> ${lvpxml} <<-EOF
<item type="text">
<position x="0" y="$(( 95 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))">
<size w="5" h="5">
<text>${title}</text>
</item>
EOF
offset=$(( ${offset} + 10 ))
fi
fi
echo "File is ${file##*/}"
lvp_read tmp "${time}" Time to get thumbnail from [${time}]:
[ -n "${tmp}" ] && time="${tmp}"
echo -n "Creating thumbnail ... "
if create_thumbnail "$file" $item "$time" ; then
mv $item.color.rgb livesystem/${file%/*}/
mv $item.gray.rgb livesystem/${file%/*}/
echo "done"
else
echo "failed"
echo "Using traditional display."
fi
button_text=${file%.*}
button_text=${button_text##*- }
lvp_read tmp "${button_text}" Enter button text for ${file} [${button_text}]:
[ -z "${tmp}" ] || button_text=${tmp}
if [ -e livesystem/${file%/*}/$item.color.rgb ] ; then
cat >> ${lvpxml} <<-EOF
<item type="buttontexture">
<texture normal=".${file%/*}/$item.gray.rgb" over=".${file%/*}/$item.color.rgb" pressed=".${file%/*}/$item.color.rgb" />
<position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
<action>/usr/bin/mplayer -fs -zoom -alang en ${mplayer_param} '${file}'</action>
<size w="40" h="40" />
</item>
<item type="text">
<position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} - 25))"
<size w="5" h="5">
<text>${button_text}</text>
</item>
EOF
else
cat >> ${lvpxml} <<-EOF
<item type="button">
<position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
<action>/usr/bin/mplayer -fs -zoom ${mplayer_param} '${file}'</action>
<size w="40" h="40" />
<text>${button_text}</text>
</item>
EOF
fi
#a little "special" for multi-language anime
if [ "${file##*.}" == "mkv" -o "${file##*.}" == "ogm" ] ; then
echo "This looks like a multi-languaged file."
confirm "Do you want to add a small button with a second language?"
if [ ${?} -eq 0 ] ; then
lvp_read alang "ja" Audio language [ja]:
lvp_read slang "en" Sub language [en]:
cat >> ${lvpxml} <<-EOF
<item type="button">
<position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - 22 - ${offset} ))" />
<action>/usr/bin/mplayer -alang ${alang} -slang ${slang} -fs -zoom ${mplayer_param} '${file}'</action>
<size w="40" h="4" />
<text>jap</text>
</item>
EOF
fi
fi
item=$(( ${item} + 1 ))
done
echo "</lvp>" >> ${lvpxml}
echo "done creating lvp.xml file"
echo "Please check that the file is correct!"
if [ ! -z ${DISPLAY} ] ; then
echo "Trying to show menu now on ${DISPLAY}"
lvp=`which lvp`
[ -z "${lvp}" ] && lvp="livesystem/usr/bin/lvp"
if ! test -x ${lvp} ; then
echo "Can't execute ${lvp}... this doesn't look good..."
else
${lvp} ${lvpxml}
fi
fi
}