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

  1. #!/bin/bash
  2. usage_create_lvpxml() {
  3. echo -n
  4. }
  5. create_thumbnail() {
  6. tmp="`mktemp`"
  7. rm -f $tmp
  8. file="$1"
  9. item=$2
  10. time=$3
  11. mplayer -nosound -vo png -ss $time -frames 2 "livesystem/$file" >/dev/null 2>&1
  12. orig="00000002.png"
  13. [ ! -f "${orig}" ] && orig="00000001.png"
  14. [ ! -f "${orig}" ] && return 1
  15. convert -resize '128x128!' ${orig} SGI:$tmp
  16. convert -depth 8 -size 128x128 SGI:$tmp gray:$tmp.tmp
  17. convert -depth 8 -size 128x128 gray:$tmp.tmp SGI:$tmp.gray
  18. mv $tmp $item.color.rgb
  19. mv $tmp.gray $item.gray.rgb
  20. rm -f $tmp*
  21. rm -f 000*
  22. return 0
  23. }
  24. process_create_lvpxml() {
  25. unset files
  26. unset title
  27. unset titleold
  28. time="00:02:00"
  29. offset=0
  30. for x in ${!file_*} ; do
  31. [ -z "${files}" ] || files="${files}\n"
  32. files="${files}${x}" # note: we're not dereferencing the variables here to keep the order the user specified
  33. done
  34. files=`echo -e ${files} | sort`
  35. rm -f ${lvpxml}
  36. touch ${lvpxml}
  37. echo "Creating lvp.xml file"
  38. echo "<lvp>" >${lvpxml}
  39. item=0
  40. for file in ${files} ; do
  41. eval "file=\${${file}}" # dereference the variable to get the real file
  42. title=${file##*/}
  43. title=${title%% -*}
  44. if [ "${title}" != "${titleold}" ] ; then
  45. titleold=${title}
  46. echo "Found possible new title \"${title}\""
  47. confirm "Do you want to start a new headline?"
  48. if [ ${?} -eq 0 ] ; then
  49. [ ${offset} -gt 0 ] && offset=$(( ${offset} + 2 ))
  50. [ $(( ${item} % 4 )) -gt 0 ] && item=$(( ${item} + ( 4 - ( ${item} % 4 ) ) ))
  51. lvp_read tmp "${title}" Please enter new title [${title}]:
  52. [ -z "${tmp}" ] || title="${tmp}"
  53. cat >> ${lvpxml} <<-EOF
  54. <item type="text">
  55. <position x="0" y="$(( 95 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))">
  56. <size w="5" h="5">
  57. <text>${title}</text>
  58. </item>
  59. EOF
  60. offset=$(( ${offset} + 10 ))
  61. fi
  62. fi
  63. echo "File is ${file##*/}"
  64. lvp_read tmp "${time}" Time to get thumbnail from [${time}]:
  65. [ -n "${tmp}" ] && time="${tmp}"
  66. echo -n "Creating thumbnail ... "
  67. if create_thumbnail "$file" $item "$time" ; then
  68. mv $item.color.rgb livesystem/${file%/*}/
  69. mv $item.gray.rgb livesystem/${file%/*}/
  70. echo "done"
  71. else
  72. echo "failed"
  73. echo "Using traditional display."
  74. fi
  75. button_text=${file%.*}
  76. button_text=${button_text##*- }
  77. lvp_read tmp "${button_text}" Enter button text for ${file} [${button_text}]:
  78. [ -z "${tmp}" ] || button_text=${tmp}
  79. if [ -e livesystem/${file%/*}/$item.color.rgb ] ; then
  80. cat >> ${lvpxml} <<-EOF
  81. <item type="buttontexture">
  82. <texture normal=".${file%/*}/$item.gray.rgb" over=".${file%/*}/$item.color.rgb" pressed=".${file%/*}/$item.color.rgb" />
  83. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
  84. <action>/usr/bin/mplayer -fs -zoom -alang en ${mplayer_param} '${file}'</action>
  85. <size w="40" h="40" />
  86. </item>
  87. <item type="text">
  88. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} - 25))"
  89. <size w="5" h="5">
  90. <text>${button_text}</text>
  91. </item>
  92. EOF
  93. else
  94. cat >> ${lvpxml} <<-EOF
  95. <item type="button">
  96. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
  97. <action>/usr/bin/mplayer -fs -zoom ${mplayer_param} '${file}'</action>
  98. <size w="40" h="40" />
  99. <text>${button_text}</text>
  100. </item>
  101. EOF
  102. fi
  103. #a little "special" for multi-language anime
  104. if [ "${file##*.}" == "mkv" -o "${file##*.}" == "ogm" ] ; then
  105. echo "This looks like a multi-languaged file."
  106. confirm "Do you want to add a small button with a second language?"
  107. if [ ${?} -eq 0 ] ; then
  108. lvp_read alang "ja" Audio language [ja]:
  109. lvp_read slang "en" Sub language [en]:
  110. cat >> ${lvpxml} <<-EOF
  111. <item type="button">
  112. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - 22 - ${offset} ))" />
  113. <action>/usr/bin/mplayer -alang ${alang} -slang ${slang} -fs -zoom ${mplayer_param} '${file}'</action>
  114. <size w="40" h="4" />
  115. <text>jap</text>
  116. </item>
  117. EOF
  118. fi
  119. fi
  120. item=$(( ${item} + 1 ))
  121. done
  122. echo "</lvp>" >> ${lvpxml}
  123. echo "done creating lvp.xml file"
  124. echo "Please check that the file is correct!"
  125. if [ ! -z ${DISPLAY} ] ; then
  126. echo "Trying to show menu now on ${DISPLAY}"
  127. lvp=`which lvp`
  128. [ -z "${lvp}" ] && lvp="livesystem/usr/bin/lvp"
  129. if ! test -x ${lvp} ; then
  130. echo "Can't execute ${lvp}... this doesn't look good..."
  131. else
  132. ${lvp} ${lvpxml}
  133. fi
  134. fi
  135. }