slitaz-tools view tinyutils/burnbox @ rev 390
Add desktop file for Documentation --> GNU GPL
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu Oct 01 21:38:06 2009 +0200 (2009-10-01) |
parents | 6d5c9793798c |
children | c14cadfb4beb |
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
8 # Authors : Christophe Lincoln <pankso@slitaz.org>
9 # Rohit Joshi <jozee@slitaz.org>
10 #
11 VERSION=20090722
12 TMPDIR="/tmp/burn-cd"
14 chk_install()
15 {
16 for pkg in $@
17 do
18 if [ ! -d /var/lib/tazpkg/installed/${pkg} ]; then
19 UNINSTALLED="$UNINSTALLED $pkg"
20 fi
21 done
22 if [ ! "$UNINSTALLED" = "" ] ; then
23 xterm -bg gray93 -fg black -geometry 80x16 -title "INSTALL PACKAGE" \
24 -e "echo -n \"this option depends on $UNINSTALLED Please install and try again\"; sleep 4;"
25 fi
26 }
29 # Check read write permission for device.
30 chk_rw_permissions()
31 {
32 xterm -bg gray93 -fg black -geometry 80x16 -title "Check Permission" \
33 -e '
34 if [ ! -r "$DEVICE" -o ! -w "$DEVICE" ]; then
35 echo "you dont have read write permission for $DEVICE; trying adding yourself to group cdrom."
36 else
37 echo "you have read write permission for $DEVICE. You can proceed to burn."
38 fi
39 sleep 3;
40 '
41 }
43 # Display audio cd size.
44 audio_cd_stats()
45 {
46 AUDIO_CD_SIZE=`du -m $TMPDIR | awk '{print $1}'`
47 TRACK_NB=`ls -1 $TMPDIR | wc -l`
48 echo -n "Total tracks: $AUDIO_CD_SIZE Mb"
49 }
51 # Display cd/dvd size.
52 disc_stats()
53 {
54 DISC_SIZE=`du -m $TMPDIR | awk '{print $1}'`
55 TRACK_NB=`ls -1 $TMPDIR | wc -l`
56 echo -n "Total size: $DISC_SIZE Mb"
57 }
60 decode_ogg()
61 {
62 if ls $TMPDIR | grep -q .ogg; then
63 cd $TMPDIR
64 xterm -bg gray93 -fg black -geometry 80x16 -title "Oggdec" \
65 -e 'for i in *.ogg; do oggdec "$i" && rm "$i"; done; sleep 2'
66 fi
67 }
69 decode_mp3()
70 {
72 if ls $TMPDIR | grep -q .mp3; then
73 cd $TMPDIR
74 UNINSTALLED=""
75 chk_install "mpg123"
76 if [ "$UNINSTALLED" = "" ] ; then
77 xterm -bg gray93 -fg black -geometry 80x16 -title "mpg123" \
78 -e 'for file in *.mp3; do
79 mpg123 --rate 44100 --stereo --buffer 3072 --resync -w `basename "$file" .mp3`.wav "$file" && rm "$file";
80 done; sleep 2'
82 fi
83 fi
84 }
86 decode_video()
87 {
88 # convert videos into a VCD/SVCD/DVD compatible mpg video format
89 if ls $TMPDIR | grep -q ".avi\|.mov\|.wmv\|.flv" ; then
90 cd $TMPDIR
91 UNINSTALLED=""
92 chk_install "ffmpeg"
94 if [ "$UNINSTALLED" = "" ] ; then
95 xterm -bg gray93 -fg black -geometry 80x16 -title "ffmpeg" \
96 -e ' echo -n "Select target type (pal-vcd ntsc-vcd pal-svcd ntsc-svcd pal-dvd ntsc-dvd) "; read TARGET_OPTIONS
97 for file in *.avi *.wmv *.mov *.flv; do
98 ext=`echo "${file##*.}"`
99 output_file=`basename "$file" .$ext`.mpg
100 ffmpeg -i "$file" -target "$TARGET_OPTIONS" "$output_file" && rm "$file";
101 done; sleep 2;
102 '
103 fi
104 fi
107 }
109 # convert spaces in filename with _ and remove special characters "()'&" {}\! and translate uppercase to lowercase
110 fix_filename()
111 {
112 ls /tmp/burn-cd/* | while read file
113 do
114 mv "$file" `echo $file | tr ' ' '_' | tr -d '[{}(),\!&]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g' `
115 done
117 }
119 # We must think about " space " between directory/track and
120 # filter directory copy to avoid copying other files than audio.
121 # Only burning non-compressed wav format is supported directly.
123 copy_audio_file()
124 {
125 if ls "$NEW_TRACK" | grep -q .ogg; then
126 cp "${NEW_TRACK%.ogg}.ogg" $TMPDIR
127 fix_filename
128 decode_ogg
129 elif ls "$NEW_TRACK" | grep -q ".[m\|M][p\|P]3"; then
130 # cp "${NEW_TRACK%.mp3}.mp3" $TMPDIR
131 cp "$NEW_TRACK" "$TMPDIR"
132 fix_filename
133 decode_mp3
134 else
135 cp "${NEW_TRACK%.wav}.wav" $TMPDIR
136 fi
137 }
140 copy_audio_dir()
141 {
143 for i in .wav .ogg .mp3
144 do
145 cp "$NEW_DIR"/*$i $TMPDIR 2>/dev/null
146 done
147 fix_filename
148 decode_ogg
149 decode_mp3
150 }
152 # Only burning mpg video format is supported directly. MPEG-1 video for vcd and MPEG-2 for svcd and dvd
153 copy_video_file()
154 {
155 if ls "$NEW_TRACK" | grep -q ".mpg\|.mpeg"; then
156 cp "${NEW_TRACK%.mp*}.mpg" $TMPDIR
157 elif ls "$NEW_TRACK" | grep -q ".avi\|.mov\|.wmv\|.flv"; then
158 ext=`echo "${NEW_TRACK##*.}"`
159 cp "${NEW_TRACK%.$ext}.$ext" $TMPDIR
160 fix_filename
161 if "$CHECKBOX_DECODE" ; then decode_video ; fi
162 else
163 echo "mpg format supported"
164 fi
165 }
167 copy_video_dir()
168 {
169 for i in .mpg .avi .mov .wmv .mpeg .flv
170 do
171 cp "$NEW_DIR"/*$i $TMPDIR 2>/dev/null
172 done
173 fix_filename
174 if "$CHECKBOX_DECODE" ; then decode_video ; fi
175 }
177 copy_file()
178 {
179 case "$BURN_MODE" in
180 audio-cd)
181 copy_audio_file ;;
182 vcd|svcd|video-dvd)
183 copy_video_file ;;
184 *)
185 cp "$NEW_TRACK" $TMPDIR ; fix_filename ;;
186 esac
188 }
190 copy_dir()
191 {
192 case "$BURN_MODE" in
193 audio-cd)
194 copy_audio_dir ;;
195 vcd|svcd|video-dvd)
196 copy_video_dir ;;
197 *)
198 cp "$NEW_DIR" $TMPDIR 2>/dev/null
199 fix_filename ;;
200 esac
201 }
202 # =====ISO=====
203 burn_iso()
204 {
205 xterm -bg gray93 -fg black -geometry 80x16 -title "Wodim" \
206 -e "wodim -v speed=$SPEED dev=$DEVICE $OPTIONS $ISO_IMAGE; sleep 4
207 "
208 }
209 # =====AUDIO=====
210 # Use -pad to avoid file size error.
211 burn_audio()
212 {
213 UNINSTALLED=""
214 chk_install "cdrkit"
215 if [ "$UNINSTALLED" = "" ] ; then
216 xterm -bg gray93 -fg black -geometry 80x16 -title "Wodim:AUDIO" \
217 -e " echo \"BURN TYPE SELECTED = $BURN_MODE \"; sleep 1;
218 wodim -v speed=$SPEED dev=$DEVICE $OPTIONS -pad -dao -audio $TMPDIR/*.wav; sleep 4
220 "
221 fi
222 }
223 # =====DATA=====
224 burn_cddata()
225 {
226 UNINSTALLED=""
227 chk_install "cdrkit"
228 if [ "$UNINSTALLED" = "" ] ; then
229 xterm -bg gray93 -fg black -geometry 80x16 -title "Wodim:CD DATA" \
230 -e " echo \"BURN TYPE SELECTED = $BURN_MODE \"; sleep 1;
231 wodim -v speed=$SPEED dev=$DEVICE $OPTIONS -pad -dao -data $TMPDIR/*; sleep 4
233 "
234 fi
236 }
238 burn_dvddata()
239 {
240 # For multisession support, remove --dvd-compat option
241 UNINSTALLED=""
242 chk_install "dvd+rw-tools"
243 if [ "$UNINSTALLED" = "" ] ; then
244 xterm -bg gray93 -fg black -geometry 80x16 -title "growisofs:DVD DATA" \
245 -e " echo \"BURN TYPE SELECTED = $BURN_MODE \"; sleep 1;
246 # no iso-file available
247 growisofs -dvd-compat -speed=$SPEED -pad -J -r -f -Z $DEVICE $TMPDIR/*; sleep 4
248 "
249 fi
250 }
252 # ====VIDEO=====
253 burn_dvdvideo()
254 {
255 UNINSTALLED=""
256 chk_install "dvd+rw-tools"
258 # current assumption: compatible dvd-video format
259 if [ "$UNINSTALLED" = "" ] ; then
260 xterm -bg gray93 -fg black -geometry 80x16 -title "growisofs:DVD VIDEO" \
261 -e " echo \"BURN TYPE SELECTED = $BURN_MODE\"; sleep 1;
262 growisofs -dvd-video -udf -pad -J -r -f -Z $DEVICE -speed=$SPEED $TMPDIR/*; sleep 2
263 "
264 fi
265 }
267 burn_vcd()
268 {
269 UNINSTALLED=""
270 chk_install "vcdimager"
271 if [ "$UNINSTALLED" = "" ] ; then
272 mkdir -p $TMPDIR/vcd
273 xterm -bg gray93 -fg black -geometry 80x16 -title "vcdimager:VCD" \
274 -e " echo \"BURN TYPE SELECTED = $BURN_MODE $UNINSTALLED \"; sleep 1;
275 vcdimager -t vcd2 -l VCD -c $TMPDIR/vcd/vcd.cue -b $TMPDIR/vcd/vcd.bin $TMPDIR/*.mpg; sleep 2;
276 # cdrdao write --device $DEVICE $TMPDIR/vcd/vcd.cue; sleep 2
277 wodim -v speed=$SPEED dev=$DEVICE $OPTIONS -pad -dao cuefile=$TMPDIR/vcd/vcd.cue ; sleep 2
278 "
279 fi
281 }
283 burn_svcd()
284 {
285 UNINSTALLED=""
286 chk_install "vcdimager"
287 if [ "$UNINSTALLED" = "" ] ; then
288 mkdir -p $TMPDIR/svcd
289 xterm -bg gray93 -fg black -geometry 80x16 -title "vcdimager:SVCD" \
290 -e " echo \"BURN TYPE SELECTED = $BURN_MODE\"
291 vcdimager -t svcd -l SVCD -c $TMPDIR/svcd/svcd.cue -b $TMPDIR/svcd/svcd.bin $TMPDIR/*.mpg; sleep 2;
292 # cdrdao write --device $DEVICE $TMPDIR/svcd/svcd.cue; sleep 2;
293 wodim -v speed=$SPEED dev=$DEVICE $OPTIONS -pad -dao cuefile=$TMPDIR/svcd/svcd.cue ; sleep 2
294 "
295 fi
296 }
298 # =====CLONE=====
300 rip_disc()
301 {
302 SUGGESTED="cdrkit-isoinfo"
303 if ! "$CHECKBOX_FOLDER" ; then SAVE_DISC="/tmp/burn-cd" ; fi
304 if [ -d /var/lib/tazpkg/installed/${SUGGESTED} ]; then
305 xterm -bg gray93 -fg black -geometry 80x16 -title "dd" \
306 -e ' echo "RIPPING DISC $DEVICE AT $SAVE_DISC..."
307 COUNT=`isoinfo -d -i $DEVICE | grep "^Volume size is:" | cut -d " " -f 4`
308 BLOCK=`isoinfo -d -i $DEVICE | grep "^Logical block size is:" | cut -d " " -f 5`
309 dd if=$DEVICE of=$SAVE_DISC/image.iso bs=$BLOCK count=$COUNT; sleep 4
310 sleep 2;
311 # eject ;
312 '
313 else
314 xterm -bg gray93 -fg black -geometry 80x16 -title "dd" \
315 -e ' echo " Though you dont have the cdrkit-isoinfo package installed, \
316 you can still rip but it may be slower"
317 echo -n "would you like to continue (y/N)? : "; read ans
318 if [ "$ans" = "y" ]; then
319 echo "RIPPING DISC $DEVICE AT $SAVE_DISC...."
320 dd if=$DEVICE of=$SAVE_DISC/image.iso;
321 sleep 2;
322 #eject ;
323 fi
324 '
325 fi
326 if ! "$CHECKBOX_FOLDER" ; then
327 ISO_IMAGE="/tmp/burn-cd/image.iso"
328 xterm -bg gray93 -fg black -geometry 80x16 -title "dd" \
329 -e ' echo -e " ---Please insert EMPTY DISC at $DEVICE ---\n ---press ENTER to continue..." && read close;'
330 burn_iso
331 fi
332 }
334 blank_dvd()
335 {
336 xterm -bg gray93 -fg black -geometry 80x16 -title "growisofs:DVD ERASE" \
337 -e "growisofs -Z $DEVICE=/dev/zero"
338 }
340 burn_disc()
341 {
342 case "$BURN_MODE" in
343 audio*)
344 burn_audio ;;
345 data-cd*)
346 burn_cddata ;;
347 data-dvd*)
348 burn_dvddata;;
349 video*)
350 burn_dvdvideo;;
351 vcd*)
352 burn_vcd;;
353 svcd*)
354 burn_svcd;;
355 esac
357 }
359 # Main GTK interface
360 MAIN_DIALOG='
361 <window title="SliTaz - Burnbox" icon-name="drive-optical">
362 <vbox>
364 <notebook labels="General|Burn ISO or Backup Disc| Burn CD/DVD (Audio,Video,Data)">
366 <vbox>
367 <frame Information>
369 <text width_request="250" use-markup="true">
370 <label>
371 "Burns iso, backs up CD/DVD, burns data CD/DVD, audio CD, video CD (VCD/SVCD)
372 "
373 </label>
374 </text>
375 <hbox>
376 <text use-markup="true">
377 <label> "<b> Please consult HELP file if needed: </b>" </label>
378 </text>
379 <button>
380 <input file icon="help"></input>
381 <action> firefox /usr/share/doc/burnbox/burnbox.html </action>
382 </button>
383 </hbox>
385 </frame>
386 <frame Settings>
387 <text>
388 <label>
389 " Before burning, please verify/change device writer settings below if needed.
390 "
391 </label>
392 </text>
394 <hbox>
395 <text use-markup="true">
396 <label>"<b>Device: </b>"</label>
397 </text>
398 <entry>
399 <default>/dev/cdrom</default>
400 <variable>DEVICE</variable>
401 </entry>
402 </hbox>
403 <hbox>
404 <text use-markup="true">
405 <label>"<b>Speed: </b>"</label>
406 </text>
407 <entry>
408 <input>cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3</input>
409 <variable>SPEED</variable>
410 </entry>
411 </hbox>
412 <hbox>
413 <text use-markup="true">
414 <label>"<b>Options: </b>"</label>
415 </text>
416 <entry>
417 <default>-eject -multi</default>
418 <variable>OPTIONS</variable>
419 </entry>
420 <button>
421 <input file icon="help"></input>
422 <action>xterm -sb -bg gray93 -fg black -geometry 95x25 -title "wodim help" -e "wodim --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
423 </button>
424 </hbox>
425 <hbox>
426 <text use-markup="true">
427 <label> "<b>Check Permission for Device: </b>" </label>
428 </text>'
429 MAIN_DIALOG=${MAIN_DIALOG}" <button>
430 <input file icon=\"dialog-information\"></input>
431 <action>$0 chk_rw_permissions</action>
432 </button> "
433 MAIN_DIALOG=${MAIN_DIALOG}'</hbox>
434 </frame>
435 <frame Blank CD/DVD-RW>
436 <hbox>
437 <text use-markup="true">
438 <label>"<b>Option: </b>"</label>
439 </text>
440 <entry>
441 <variable>BLANK_OPTS</variable>
442 <default>fast</default>
443 </entry>
444 <button>
445 <input file icon="help"></input>
446 <action>xterm -bg gray93 -fg black -geometry 80x15 -title "wodim blank=help" -e "wodim blank=help ; echo -e \"----\nENTER to continue...\" && read close"</action>
447 </button>
448 <button>
449 <label>Blank disc</label>
450 <input file icon="forward"></input>
451 <action>xterm -bg gray93 -fg black -title "Wodim" -e "wodim -v -blank=$BLANK_OPTS dev=$DEVICE; sleep 2"</action>
452 </button>
453 </hbox>
454 </frame>
455 </vbox>
457 <vbox>
458 <frame Select ISO and burn>
459 <hbox>
460 <text>
461 <label>
462 " "
463 </label>
464 </text>
465 <text use-markup="true">
466 <label>"<b>ISO path:</b>"</label>
467 </text>
468 <entry>
469 <variable>ISO_IMAGE</variable>
470 </entry>
471 <button>
472 <label>Browse</label>
473 <input file stock="gtk-open"></input>
474 <action type="fileselect">ISO_IMAGE</action>
475 </button>
476 '
477 # Burn iso button.
478 MAIN_DIALOG=${MAIN_DIALOG}"
479 <button>
480 <label>Burn ISO</label>
481 <input file icon=\"forward\"></input>
482 <action>$0 burn_iso</action>
483 </button>
484 </hbox>"
485 # Backup CD
486 MAIN_DIALOG=${MAIN_DIALOG}'
487 </frame>
489 <frame Data CD/DVD backup >
490 <text>
491 <label>
492 " "
493 </label>
494 </text>
495 <checkbox>
496 <label>Save backup on Hard disk (Unselect to backup on CD disc) </label>
497 <variable>CHECKBOX_FOLDER</variable>
498 <default>true</default>
499 <action>if true enable:SAVE_DISC</action>
500 <action>if true enable:OPENBUTTON</action>
501 <action>if false disable:SAVE_DISC</action>
502 <action>if false disable:OPENBUTTON</action>
503 </checkbox>
504 <hbox>
505 <text use-markup="true">
506 <label>"<b> Backup folder:</b>"</label>
507 </text>
508 <entry accept="directory">
509 <label>Select a folder to save cloned disc to</label>
510 <variable>SAVE_DISC</variable>
511 </entry>
512 <button>
513 <label>Browse</label>
514 <input file stock="gtk-open"></input>
515 <variable>OPENBUTTON</variable>
516 <action type="fileselect">SAVE_DISC</action>
517 </button>
518 '
519 # Burn backup button.
520 MAIN_DIALOG=${MAIN_DIALOG}"
521 <button>
522 <label>Backup DataCD</label>
523 <variable>DATA_RIP</variable>
524 <input file icon=\"forward\"></input>
525 <action>$0 rip_disc</action>
526 </button>
527 </hbox>"
528 MAIN_DIALOG=${MAIN_DIALOG}'
529 </frame>
530 <frame Audio CD backup>
531 <hbox>
532 <text>
533 <label> " audio CD clone using asunder " </label>
534 </text>
535 <button>
536 <label> Backup AudioCD</label>
537 <variable>AUDIO_RIP</variable>
538 <input file icon="forward"></input>
539 <action>asunder</action>
540 </button>
541 </hbox>
542 </frame>
544 </vbox>
545 <vbox>
546 <tree icon_name="audio-x-generic">
547 <width>500</width><height>200</height>
548 <variable>TRACKS_LIST</variable>
549 <label>Track name (Double-click to remove a track)</label>
550 <input>ls -1 /tmp/burn-cd</input>
551 <action>rm "/tmp/burn-cd/$TRACKS_LIST"</action>
552 <action>refresh:TRACKS_LIST</action>
553 <action>refresh:TRACKS_SIZE</action>
554 </tree>'
555 # Select burn audio-cd, data-cd, dvd-video or vcd/svcd
556 MAIN_DIALOG=${MAIN_DIALOG}'
557 <frame>
558 <hbox>
559 <text>
560 <label> Select Burn type: </label>
561 </text>
562 <combobox>'
563 tmp2="${MAIN_DIALOG}"
564 for i in audio-cd data-cd data-dvd video-dvd vcd svcd; do
565 [ "$i" = "$BURN_MODE" ] || tmp2="$tmp2<item>$i</item>"
566 done
567 tmp3='
568 <variable>BURN_MODE</variable>
569 </combobox>
570 <checkbox>
571 <label> Enable decoding video</label>
572 <variable>CHECKBOX_DECODE</variable>
573 <default>true</default>
574 </checkbox>
575 </hbox>
576 '
577 MAIN_DIALOG="$tmp2$tmp3"
578 # Select, add and burn audio buttons.
579 MAIN_DIALOG=${MAIN_DIALOG}"
580 <hbox>
581 <text>
582 <label> File: </label>
583 </text>
584 <entry accept=\"filename\">
585 <label>Select an Audio/Video/data track</label>
586 <variable>NEW_TRACK</variable>
587 </entry>
588 <button>
589 <label>Browse</label>
590 <input file stock=\"gtk-open\"></input>
591 <action type=\"fileselect\">NEW_TRACK</action>
592 </button>
593 <button>
594 <label>Add</label>
595 <input file stock=\"gtk-add\"></input>
596 <action>$0 copy_file</action>
597 <action>refresh:TRACKS_LIST</action>
598 <action>refresh:TRACKS_SIZE</action>
599 </button>
600 </hbox>
601 <hbox>
602 <text>
603 <label> Folder:</label>
604 </text>
605 <entry accept=\"directory\">
606 <label>Select an Audio/Video/Data track</label>
607 <variable>NEW_DIR</variable>
608 </entry>
609 <button>
610 <label>Browse</label>
611 <input file stock=\"gtk-open\"></input>
612 <action type=\"fileselect\">NEW_DIR</action>
613 </button>
614 <button>
615 <label>Add</label>
616 <input file stock=\"gtk-add\"></input>
617 <action>$0 copy_dir</action>
618 <action>refresh:TRACKS_LIST</action>
620 <action>refresh:TRACKS_SIZE</action>
621 </button>
622 </hbox>"
624 MAIN_DIALOG=${MAIN_DIALOG}"
625 <hbox>
626 <text>
627 <variable>TRACKS_SIZE</variable>
628 <input>$0 audio_cd_stats</input>
629 </text>
630 <button>
631 <label>Clean</label>
632 <input file stock=\"gtk-clear\"></input>
633 <action>rm -rf $TMPDIR/*</action>
634 <action>refresh:TRACKS_LIST</action>
635 <action>refresh:TRACKS_SIZE</action>
636 <action>clear:NEW_TRACK</action>
637 <action>clear:NEW_DIR</action>
638 </button>
639 <button>
640 <label>Burn disc</label>
641 <input file icon=\"forward\"></input>
642 <action>$0 burn_disc</action>
643 </button>
644 </hbox>
645 </frame>
646 </vbox> "
647 #
648 #
649 # tmp3=
650 export MAIN_DIALOG=${MAIN_DIALOG}'
652 </notebook>
654 <hbox>
655 <button>
656 <label>Exit</label>
657 <input file icon="exit"></input>
658 <action type="exit">Exit</action>
659 </button>
660 </hbox>
662 </vbox>
663 </window>
664 '
666 # Script can be called with an arg to exec a function.
667 if [ -n "$1" ]; then
668 $1
669 else
670 mkdir -p $TMPDIR
671 gtkdialog --center --program=MAIN_DIALOG >/dev/null
672 rm -rf $TMPDIR
673 fi
675 exit 0