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.

170 lines
5.5 KiB

  1. #!/bin/bash
  2. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  3. #
  4. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  5. # Please add additional copyright information _after_ the line containing
  6. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  7. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  8. #
  9. # ROCK Linux: rock-src/target/lvp/x86/release_skeleton/scripts/create_lvpxml
  10. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License, or
  15. # (at your option) any later version. A copy of the GNU General Public
  16. # License can be found at Documentation/COPYING.
  17. #
  18. # Many people helped and are helping developing ROCK Linux. Please
  19. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  20. # file for details.
  21. #
  22. # --- ROCK-COPYRIGHT-NOTE-END ---
  23. usage_create_lvpxml() {
  24. echo -n
  25. }
  26. create_thumbnail() {
  27. tmp="`mktemp`"
  28. rm -f $tmp
  29. file="$1"
  30. item=$2
  31. time=$3
  32. mplayer -nosound -vo png -ss $time -frames 2 "livesystem/$file" >/dev/null 2>&1
  33. orig="00000002.png"
  34. [ ! -f "${orig}" ] && orig="00000001.png"
  35. [ ! -f "${orig}" ] && return 1
  36. convert -resize '128x128!' ${orig} SGI:$tmp
  37. convert -depth 8 -size 128x128 SGI:$tmp gray:$tmp.tmp
  38. convert -depth 8 -size 128x128 gray:$tmp.tmp SGI:$tmp.gray
  39. mv $tmp $item.color.rgb
  40. mv $tmp.gray $item.gray.rgb
  41. rm -f $tmp*
  42. rm -f 000*
  43. return 0
  44. }
  45. process_create_lvpxml() {
  46. unset files
  47. unset title
  48. unset titleold
  49. time="00:02:00"
  50. offset=0
  51. for x in ${!file_*} ; do
  52. [ -z "${files}" ] || files="${files}\n"
  53. files="${files}${x}" # note: we're not dereferencing the variables here to keep the order the user specified
  54. done
  55. files=`echo -e ${files} | sort`
  56. rm -f ${lvpxml}
  57. touch ${lvpxml}
  58. echo "Creating lvp.xml file"
  59. echo "<lvp>" >${lvpxml}
  60. item=0
  61. for file in ${files} ; do
  62. eval "file=\${${file}}" # dereference the variable to get the real file
  63. title=${file##*/}
  64. title=${title%% -*}
  65. if [ "${title}" != "${titleold}" ] ; then
  66. titleold=${title}
  67. echo "Found possible new title \"${title}\""
  68. confirm "Do you want to start a new headline?"
  69. if [ ${?} -eq 0 ] ; then
  70. [ ${offset} -gt 0 ] && offset=$(( ${offset} + 2 ))
  71. [ $(( ${item} % 4 )) -gt 0 ] && item=$(( ${item} + ( 4 - ( ${item} % 4 ) ) ))
  72. lvp_read tmp "${title}" Please enter new title [${title}]:
  73. [ -z "${tmp}" ] || title="${tmp}"
  74. cat >> ${lvpxml} <<-EOF
  75. <item type="text">
  76. <position x="0" y="$(( 95 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))">
  77. <size w="5" h="5">
  78. <text>${title}</text>
  79. </item>
  80. EOF
  81. offset=$(( ${offset} + 10 ))
  82. fi
  83. fi
  84. echo "File is ${file##*/}"
  85. lvp_read tmp "${time}" Time to get thumbnail from [${time}]:
  86. [ -n "${tmp}" ] && time="${tmp}"
  87. echo -n "Creating thumbnail ... "
  88. if create_thumbnail "$file" $item "$time" ; then
  89. mv $item.color.rgb livesystem/${file%/*}/
  90. mv $item.gray.rgb livesystem/${file%/*}/
  91. echo "done"
  92. else
  93. echo "failed"
  94. echo "Using traditional display."
  95. fi
  96. button_text=${file%.*}
  97. button_text=${button_text##*- }
  98. lvp_read tmp "${button_text}" Enter button text for ${file} [${button_text}]:
  99. [ -z "${tmp}" ] || button_text=${tmp}
  100. if [ -e livesystem/${file%/*}/$item.color.rgb ] ; then
  101. cat >> ${lvpxml} <<-EOF
  102. <item type="buttontexture">
  103. <texture normal=".${file%/*}/$item.gray.rgb" over=".${file%/*}/$item.color.rgb" pressed=".${file%/*}/$item.color.rgb" />
  104. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
  105. <action>/usr/bin/mplayer -fs -zoom -alang en ${mplayer_param} '${file}'</action>
  106. <size w="40" h="40" />
  107. </item>
  108. <item type="text">
  109. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} - 25))"
  110. <size w="5" h="5">
  111. <text>${button_text}</text>
  112. </item>
  113. EOF
  114. else
  115. cat >> ${lvpxml} <<-EOF
  116. <item type="button">
  117. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
  118. <action>/usr/bin/mplayer -fs -zoom ${mplayer_param} '${file}'</action>
  119. <size w="40" h="40" />
  120. <text>${button_text}</text>
  121. </item>
  122. EOF
  123. fi
  124. #a little "special" for multi-language anime
  125. if [ "${file##*.}" == "mkv" -o "${file##*.}" == "ogm" ] && [ "${LVP_USE_MULTI_LANGUAGE}" == "1" ] ; then
  126. echo "This looks like a multi-languaged file."
  127. confirm "Do you want to add a small button with a second language?"
  128. if [ ${?} -eq 0 ] ; then
  129. lvp_read alang "ja" Audio language [ja]:
  130. lvp_read slang "en" Sub language [en]:
  131. lvp_read sub "ja" Button text [ja]:
  132. cat >> ${lvpxml} <<-EOF
  133. <item type="button">
  134. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - 22 - ${offset} ))" />
  135. <action>/usr/bin/mplayer -alang ${alang} -slang ${slang} -fs -zoom ${mplayer_param} '${file}'</action>
  136. <size w="40" h="4" />
  137. <text>${sub}</text>
  138. </item>
  139. EOF
  140. fi
  141. fi
  142. item=$(( ${item} + 1 ))
  143. done
  144. echo "</lvp>" >> ${lvpxml}
  145. echo "done creating lvp.xml file"
  146. echo "Please check that the file is correct!"
  147. if [ ! -z ${DISPLAY} ] ; then
  148. echo "Trying to show menu now on ${DISPLAY}"
  149. lvp=`which lvp`
  150. [ -z "${lvp}" ] && lvp="livesystem/usr/bin/lvp"
  151. if ! test -x ${lvp} ; then
  152. echo "Can't execute ${lvp}... this doesn't look good..."
  153. else
  154. ${lvp} ${lvpxml}
  155. fi
  156. fi
  157. }