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.

172 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}"
  54. # note: we're not dereferencing the variables here to keep the order
  55. # the user specified them in
  56. done
  57. files=`echo -e ${files}`
  58. rm -f ${lvpxml}
  59. touch ${lvpxml}
  60. echo "Creating lvp.xml file"
  61. echo "<lvp>" >${lvpxml}
  62. item=0
  63. for file in ${files} ; do
  64. eval "file=\${${file}}" # dereference the variable to get the real file
  65. title=${file##*/}
  66. title=${title%% -*}
  67. if [ "${title}" != "${titleold}" ] ; then
  68. titleold=${title}
  69. echo "Found possible new title \"${title}\""
  70. confirm "Do you want to start a new headline?"
  71. if [ ${?} -eq 0 ] ; then
  72. [ ${offset} -gt 0 ] && offset=$(( ${offset} + 2 ))
  73. [ $(( ${item} % 4 )) -gt 0 ] && item=$(( ${item} + ( 4 - ( ${item} % 4 ) ) ))
  74. lvp_read tmp "${title}" Please enter new title [${title}]:
  75. [ -z "${tmp}" ] || title="${tmp}"
  76. cat >> ${lvpxml} <<-EOF
  77. <item type="text">
  78. <position x="0" y="$(( 95 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
  79. <size w="5" h="5" />
  80. <text>${title}</text>
  81. </item>
  82. EOF
  83. offset=$(( ${offset} + 10 ))
  84. fi
  85. fi
  86. echo "File is ${file##*/}"
  87. lvp_read tmp "${time}" Time to get thumbnail from [${time}]:
  88. [ -n "${tmp}" ] && time="${tmp}"
  89. echo -n "Creating thumbnail ... "
  90. if create_thumbnail "$file" $item "$time" ; then
  91. mv $item.color.rgb livesystem/${file%/*}/
  92. mv $item.gray.rgb livesystem/${file%/*}/
  93. echo "done"
  94. else
  95. echo "failed"
  96. echo "Using traditional display."
  97. fi
  98. button_text=${file%.*}
  99. button_text=${button_text##*- }
  100. lvp_read tmp "${button_text}" Enter button text for ${file} [${button_text}]:
  101. [ -z "${tmp}" ] || button_text=${tmp}
  102. if [ -e livesystem/${file%/*}/$item.color.rgb ] ; then
  103. cat >> ${lvpxml} <<-EOF
  104. <item type="buttontexture">
  105. <texture normal=".${file%/*}/$item.gray.rgb" over=".${file%/*}/$item.color.rgb" pressed=".${file%/*}/$item.color.rgb" />
  106. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
  107. <action>/usr/bin/mplayer -fs -zoom -alang en ${mplayer_param} '${file}'</action>
  108. <size w="40" h="40" />
  109. </item>
  110. <item type="text">
  111. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} - 25))" />
  112. <size w="5" h="5">
  113. <text>${button_text}</text>
  114. </item>
  115. EOF
  116. else
  117. cat >> ${lvpxml} <<-EOF
  118. <item type="button">
  119. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - ${offset} ))" />
  120. <action>/usr/bin/mplayer -fs -zoom ${mplayer_param} '${file}'</action>
  121. <size w="40" h="40" />
  122. <text>${button_text}</text>
  123. </item>
  124. EOF
  125. fi
  126. #a little "special" for multi-language anime
  127. if [ "${file##*.}" == "mkv" -o "${file##*.}" == "ogm" ] && [ "${LVP_USE_MULTI_LANGUAGE}" == "1" ] ; then
  128. echo "This looks like a multi-languaged file."
  129. confirm "Do you want to add a small button with a second language?"
  130. if [ ${?} -eq 0 ] ; then
  131. lvp_read alang "ja" Audio language [ja]:
  132. lvp_read slang "en" Sub language [en]:
  133. lvp_read sub "ja" Button text [ja]:
  134. cat >> ${lvpxml} <<-EOF
  135. <item type="button">
  136. <position x="$(( (${item} % 4) * 50 - 75 ))" y="$(( 75 - ((${item} - (${item} % 4)) / 4) * 50 - 22 - ${offset} ))" />
  137. <action>/usr/bin/mplayer -alang ${alang} -slang ${slang} -fs -zoom ${mplayer_param} '${file}'</action>
  138. <size w="40" h="4" />
  139. <text>${sub}</text>
  140. </item>
  141. EOF
  142. fi
  143. fi
  144. item=$(( ${item} + 1 ))
  145. done
  146. echo "</lvp>" >> ${lvpxml}
  147. echo "done creating lvp.xml file"
  148. echo "Please check that the file is correct!"
  149. if [ -n "${DISPLAY}" ] ; then
  150. echo "Trying to show menu now on ${DISPLAY}"
  151. lvp=`which lvp`
  152. [ -z "${lvp}" ] && lvp="livesystem/usr/bin/lvp"
  153. if ! test -x ${lvp} ; then
  154. echo "Can't execute ${lvp}... this doesn't look good..."
  155. else
  156. ${lvp} ${lvpxml}
  157. fi
  158. fi
  159. }