slitaz-tools view tinyutils/burnbox @ rev 340
tazx: Moved doc to Handbook
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon May 04 23:12:18 2009 +0200 (2009-05-04) |
parents | 1ce86bd8de83 |
children | 5173d70b4b1b |
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box to burn CD or DVD using Wodim with basic options. Burnbox
4 # can burn ISO images, blank rewritable CD or create audio CD with WAV.
5 #
6 # (c) - SliTaz GNU/Linux 2009 - GNU GPL v3
7 #
8 VERSION=20090204
10 # Display audio cd size.
11 audio_cd_stats()
12 {
13 AUDIO_CD_SIZE=`du -m /tmp/audio-cd | awk '{print $1}'`
14 TRACK_NB=`ls -1 /tmp/audio-cd | wc -l`
15 echo -n "Total tracks: $AUDIO_CD_SIZE Mb"
16 }
18 decode_ogg()
19 {
20 if ls /tmp/audio-cd | grep -q .ogg; then
21 cd /tmp/audio-cd
22 xterm -bg gray93 -fg black -geometry 80x16 -title "Oggdec" \
23 -e 'for i in *.ogg; do oggdec "$i" && rm "$i"; done; sleep 2'
24 fi
25 }
27 # We must think about " space " between directory/track and
28 # filter directory copy to avoid copying other files than audio.
29 # Only burning non-compressed wav format is supported directly.
30 copy_audio_file()
31 {
32 if ls "$NEW_TRACK" | grep -q .ogg; then
33 cp "${NEW_TRACK%.ogg}.ogg" /tmp/audio-cd
34 decode_ogg
35 else
36 cp "${NEW_TRACK%.wav}.wav" /tmp/audio-cd
37 fi
38 }
39 copy_audio_dir()
40 {
41 for i in .wav .ogg
42 do
43 cp "$NEW_DIR"/*$i /tmp/audio-cd 2>/dev/null
44 done
45 decode_ogg
46 }
48 burn_iso()
49 {
50 xterm -bg gray93 -fg black -geometry 80x16 -title "Wodim" \
51 -e "wodim -v speed=$SPEED dev=$DEVICE $OPTIONS $ISO_IMAGE; sleep 4"
52 }
54 # Use -pad to avoid file size error.
55 burn_audio()
56 {
57 xterm -bg gray93 -fg black -geometry 80x16 -title "Wodim" \
58 -e "wodim -v speed=$SPEED dev=$DEVICE $OPTIONS -pad -dao -audio /tmp/audio-cd/*.wav; sleep 4"
59 }
61 # Main GTK interface
62 MAIN_DIALOG='
63 <window title="SliTaz - Burnbox" icon-name="drive-optical">
64 <vbox>
66 <notebook labels="General|ISO image|Audio CD">
68 <vbox>
69 <frame Information>
70 <text>
71 <label>
72 "Burn CD or DVD using Wodim from cdrkit. Before burning,
73 please verify device writer settings or add options if needed.
74 Audio CD uses uncompressed WAV (OGG are decoded)."
75 </label>
76 </text>
77 </frame>
78 <frame Settings>
79 <hbox>
80 <text use-markup="true">
81 <label>"<b>Device: </b>"</label>
82 </text>
83 <entry>
84 <default>/dev/cdrom</default>
85 <variable>DEVICE</variable>
86 </entry>
87 </hbox>
88 <hbox>
89 <text use-markup="true">
90 <label>"<b>Speed: </b>"</label>
91 </text>
92 <entry>
93 <input>cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3</input>
94 <variable>SPEED</variable>
95 </entry>
96 </hbox>
97 <hbox>
98 <text use-markup="true">
99 <label>"<b>Options: </b>"</label>
100 </text>
101 <entry>
102 <default>-eject -multi</default>
103 <variable>OPTIONS</variable>
104 </entry>
105 <button>
106 <input file icon="help"></input>
107 <action>xterm -sb -bg gray93 -fg black -geometry 95x25 -title "wodim help" -e "wodim --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
108 </button>
109 </hbox>
110 </frame>
111 <frame Blank CD/DVD-RW>
112 <hbox>
113 <text use-markup="true">
114 <label>"<b>Option: </b>"</label>
115 </text>
116 <entry>
117 <variable>BLANK_OPTS</variable>
118 <default>fast</default>
119 </entry>
120 <button>
121 <input file icon="help"></input>
122 <action>xterm -bg gray93 -fg black -geometry 80x15 -title "wodim blank=help" -e "wodim blank=help ; echo -e \"----\nENTER to continue...\" && read close"</action>
123 </button>
124 <button>
125 <label>Blank disk</label>
126 <input file icon="forward"></input>
127 <action>xterm -bg gray93 -fg black -title "Wodim" -e "wodim -v -blank=$BLANK_OPTS dev=$DEVICE; sleep 2"</action>
128 </button>
129 </hbox>
130 </frame>
131 </vbox>
133 <vbox>
134 <frame Select and burn>
136 <text>
137 <label>
138 "
139 You can create or manipulate ISO images with ISO Master utility
140 or use genisoimage from the command line.
141 "
142 </label>
143 </text>
145 <hbox>
146 <text use-markup="true">
147 <label>"<b>ISO path:</b>"</label>
148 </text>
149 <entry>
150 <variable>ISO_IMAGE</variable>
151 </entry>
152 <button>
153 <input file stock="gtk-cdrom"></input>
154 <action type="fileselect">ISO_IMAGE</action>
155 </button>
156 </hbox>'
157 # Burn iso button.
158 MAIN_DIALOG=${MAIN_DIALOG}"
159 <hbox>
160 <button>
161 <label>Burn disk</label>
162 <input file icon=\"forward\"></input>
163 <action>$0 burn_iso</action>
164 </button>
165 </hbox>"
166 MAIN_DIALOG=${MAIN_DIALOG}'
167 </frame>
169 </vbox>
170 <vbox>
171 <tree icon_name="audio-x-generic">
172 <width>500</width><height>200</height>
173 <variable>TRACKS_LIST</variable>
174 <label>Track name</label>
175 <input>ls -1 /tmp/audio-cd</input>
176 <action>rm "/tmp/audio-cd/$TRACKS_LIST"</action>
177 <action>refresh:TRACKS_LIST</action>
178 <action>refresh:TRACKS_SIZE</action>
179 </tree>'
180 # Select, add and burn audio buttons.
181 MAIN_DIALOG=${MAIN_DIALOG}"
182 <hbox>
183 <text>
184 <label>Title: </label>
185 </text>
186 <entry accept=\"filename\">
187 <label>Select an Audio track</label>
188 <variable>NEW_TRACK</variable>
189 </entry>
190 <button>
191 <input file stock=\"gtk-open\"></input>
192 <action type=\"fileselect\">NEW_TRACK</action>
193 </button>
194 <button>
195 <label>Add</label>
196 <input file stock=\"gtk-add\"></input>
197 <action>$0 copy_audio_file</action>
198 <action>refresh:TRACKS_LIST</action>
199 <action>refresh:TRACKS_SIZE</action>
200 </button>
201 </hbox>
202 <hbox>
203 <text>
204 <label>Album:</label>
205 </text>
206 <entry accept=\"directory\">
207 <label>Select an Audio track</label>
208 <variable>NEW_DIR</variable>
209 </entry>
210 <button>
211 <input file stock=\"gtk-open\"></input>
212 <action type=\"fileselect\">NEW_DIR</action>
213 </button>
214 <button>
215 <label>Add</label>
216 <input file stock=\"gtk-add\"></input>
217 <action>$0 copy_audio_dir</action>
218 <action>refresh:TRACKS_LIST</action>
219 <action>refresh:TRACKS_SIZE</action>
220 </button>
221 </hbox>
222 <hbox>
223 <text>
224 <variable>TRACKS_SIZE</variable>
225 <input>$0 audio_cd_stats</input>
226 </text>
227 <button>
228 <label>Clean</label>
229 <input file stock=\"gtk-clear\"></input>
230 <action>rm -rf /tmp/audio-cd/*</action>
231 <action>refresh:TRACKS_LIST</action>
232 <action>refresh:TRACKS_SIZE</action>
233 <action>clear:NEW_TRACK</action>
234 <action>clear:NEW_DIR</action>
235 </button>
236 <button>
237 <label>Burn disk</label>
238 <input file icon=\"forward\"></input>
239 <action>$0 burn_audio</action>
240 </button>
241 </hbox>
242 </vbox>"
243 export MAIN_DIALOG=${MAIN_DIALOG}'
245 </notebook>
247 <hbox>
248 <button>
249 <label>Exit</label>
250 <input file icon="exit"></input>
251 <action type="exit">Exit</action>
252 </button>
253 </hbox>
255 </vbox>
256 </window>
257 '
259 # Script can be called with an arg to exec a function.
260 if [ -n "$1" ]; then
261 $1
262 else
263 mkdir -p /tmp/audio-cd
264 gtkdialog --center --program=MAIN_DIALOG >/dev/null
265 rm -rf /tmp/audio-cd
266 fi
268 exit 0