slitaz-tools diff tinyutils/burnbox @ rev 296

desktopbox: Add autostart (GUI to enable/disable apps started with Openbox)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 21 22:33:58 2009 +0100 (2009-02-21)
parents db0e82bebc70
children af65458ca488
line diff
     1.1 --- a/tinyutils/burnbox	Sat Jul 19 06:35:45 2008 +0000
     1.2 +++ b/tinyutils/burnbox	Sat Feb 21 22:33:58 2009 +0100
     1.3 @@ -1,123 +1,268 @@
     1.4 -#! /bin/sh
     1.5 +#!/bin/sh
     1.6  # 
     1.7 -# Gtkdialog box to burn ISO images using Wodim with basic options.
     1.8 -# - SliTaz GNU/Linux 2008.
     1.9 +# Gtkdialog box to burn CD or DVD using Wodim with basic options. Burnbox
    1.10 +# can burn ISO images, blank rewritable CD or create audio CD with WAV.
    1.11 +# 
    1.12 +# (c) - SliTaz GNU/Linux 2009 - GNU GPL v3
    1.13  #
    1.14 -VERSION=20080114
    1.15 +VERSION=20090204
    1.16  
    1.17 -# Burn/wodim dialog box. Sleep a bit with progress bar to let user cancel
    1.18 -# ISO burning and exit when finished.
    1.19 -#
    1.20 -export BURN_DIALOG='
    1.21 -<window title="Burnbox working" icon-name="dialog-warning">
    1.22 -  <vbox>
    1.23 -    <text use-markup="true" width-chars="28">
    1.24 -      <label>
    1.25 +# Display audio cd size.
    1.26 +audio_cd_stats()
    1.27 +{
    1.28 +	AUDIO_CD_SIZE=`du -m /tmp/audio-cd | awk '{print $1}'`
    1.29 +	TRACK_NB=`ls -1 /tmp/audio-cd | wc -l`
    1.30 +	echo -n "Total tracks: $AUDIO_CD_SIZE Mb"
    1.31 +}
    1.32 +
    1.33 +decode_ogg()
    1.34 +{
    1.35 +	if ls /tmp/audio-cd | grep -q .ogg; then
    1.36 +		cd /tmp/audio-cd
    1.37 +		xterm -bg gray93 -fg black -geometry 80x16 -title "Oggdec" \
    1.38 +			-e 'for i in *.ogg; do oggdec "$i" && rm "$i"; done; sleep 2'
    1.39 +	fi
    1.40 +}
    1.41 +
    1.42 +# We must think about " space " between directory/track and
    1.43 +# filter directory copy to avoid copying other files than audio.
    1.44 +# Only burning non-compressed wav format is supported directly.
    1.45 +copy_audio_file()
    1.46 +{
    1.47 +	if ls "$NEW_TRACK" | grep -q .ogg; then
    1.48 +		cp "${NEW_TRACK%.ogg}.ogg" /tmp/audio-cd
    1.49 +		decode_ogg
    1.50 +	else
    1.51 +		cp "${NEW_TRACK%.wav}.wav" /tmp/audio-cd
    1.52 +	fi
    1.53 +}
    1.54 +copy_audio_dir()
    1.55 +{
    1.56 +	for i in .wav .ogg
    1.57 +	do
    1.58 +		cp "$NEW_DIR"/*$i /tmp/audio-cd 2>/dev/null
    1.59 +	done
    1.60 +	decode_ogg
    1.61 +}
    1.62 +
    1.63 +burn_iso()
    1.64 +{
    1.65 +	xterm -bg gray93 -fg black -geometry 80x16 -title "Wodim" \
    1.66 +		-e "wodim -v speed=$SPEED dev=$DEVICE $OPTIONS $ISO_IMAGE; sleep 4"
    1.67 +}
    1.68 +
    1.69 +# Use -pad to avoid file size error.
    1.70 +burn_audio()
    1.71 +{
    1.72 +	xterm -bg gray93 -fg black -geometry 80x16 -title "Wodim" \
    1.73 +		-e "wodim -v speed=$SPEED dev=$DEVICE $OPTIONS -pad -dao -audio /tmp/audio-cd/*.wav; sleep 4"
    1.74 +}
    1.75 +
    1.76 +# Main GTK interface
    1.77 +MAIN_DIALOG='
    1.78 +<window title="SliTaz - Burnbox" icon-name="drive-optical">
    1.79 +<vbox>
    1.80 +
    1.81 +	<notebook labels="General|ISO image|Audio CD">
    1.82 +	
    1.83 +	<vbox>
    1.84 +		<frame Information>
    1.85 +			<text>
    1.86 +				<label>
    1.87 +"Burn CD or DVD using Wodim from cdrkit. Before burning,
    1.88 +please verify device writer settings or add options if needed.
    1.89 +Audio CD use uncompressed WAV (OGG are decoded)."
    1.90 +				</label>
    1.91 +			</text>
    1.92 +		</frame>
    1.93 +		<frame Settings>
    1.94 +			<hbox>
    1.95 +				<text use-markup="true">
    1.96 +					<label>"<b>Device:     </b>"</label>
    1.97 +				</text>
    1.98 +				<entry>
    1.99 +					<default>/dev/cdrom</default>
   1.100 +					<variable>DEVICE</variable>
   1.101 +				</entry>
   1.102 +			</hbox>
   1.103 +			<hbox>
   1.104 +				<text use-markup="true">
   1.105 +					<label>"<b>Speed:     </b>"</label>
   1.106 +				</text>
   1.107 +				<entry>
   1.108 +					<input>cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3</input>
   1.109 +					<variable>SPEED</variable>
   1.110 +				</entry>
   1.111 +			</hbox>
   1.112 +			<hbox>
   1.113 +				<text use-markup="true">
   1.114 +					<label>"<b>Options:  </b>"</label>
   1.115 +				</text>
   1.116 +				<entry>
   1.117 +					<default>-eject -multi</default>
   1.118 +					<variable>OPTIONS</variable>
   1.119 +				</entry>
   1.120 +				<button>
   1.121 +					<input file icon="help"></input>
   1.122 +					<action>xterm -sb -bg gray93 -fg black -geometry 95x25 -title "wodim help" -e "wodim --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
   1.123 +				</button>
   1.124 +			</hbox>
   1.125 +		</frame>
   1.126 +		<frame Blank CD/DVD-RW>
   1.127 +			<hbox>
   1.128 +				<text use-markup="true">
   1.129 +					<label>"<b>Option:   </b>"</label>
   1.130 +				</text>
   1.131 +				<entry>
   1.132 +					<variable>BLANK_OPTS</variable>
   1.133 +					<default>fast</default>
   1.134 +				</entry>
   1.135 +				<button>
   1.136 +					<input file icon="help"></input>
   1.137 +					<action>xterm -bg gray93 -fg black -geometry 80x15 -title "wodim blank=help" -e "wodim blank=help ; echo -e \"----\nENTER to continue...\" && read close"</action>
   1.138 +				</button>
   1.139 +				<button>
   1.140 +					<label>Blank disk</label>
   1.141 +					<input file icon="forward"></input>
   1.142 +					<action>xterm -bg gray93 -fg black -title "Wodim" -e "wodim -v -blank=$BLANK_OPTS dev=$DEVICE; sleep 2"</action>
   1.143 +				</button>
   1.144 +			</hbox>
   1.145 +		</frame>
   1.146 +	</vbox>
   1.147 +	
   1.148 +	<vbox>
   1.149 +		<frame Select and burn>
   1.150 +		
   1.151 +			<text>
   1.152 +				<label>
   1.153  "
   1.154 -<b>Burnbox working</b>
   1.155 +You can create or manipulate ISO images with ISO Master utility
   1.156 +or use genisoimage from the command line.
   1.157  "
   1.158 -      </label>
   1.159 -    </text>
   1.160 -    <progressbar>
   1.161 -      <label>Please wait...</label>
   1.162 -      <input>for i in 15 30 45; do echo $i; sleep 1; done; echo "Burning ISO..."; wodim speed=$SPEED dev=$DEVICE $OPTIONS $ISO_IMAGE >/dev/null; echo "Done..."; for i in 60 75 90; do echo $i; sleep 1; done; echo 100</input>
   1.163 -      <action type="exit">Burned</action>
   1.164 -    </progressbar>
   1.165 -  </vbox>
   1.166 +				</label>
   1.167 +			</text>
   1.168 +		
   1.169 +			<hbox>
   1.170 +				<text use-markup="true">
   1.171 +					<label>"<b>ISO path:</b>"</label>
   1.172 +				</text>
   1.173 +				<entry>
   1.174 +					<variable>ISO_IMAGE</variable>
   1.175 +				</entry>
   1.176 +				<button>
   1.177 +					<input file stock="gtk-cdrom"></input>
   1.178 +					<action type="fileselect">ISO_IMAGE</action>
   1.179 +				</button>
   1.180 +			</hbox>'
   1.181 +# Burn iso button.
   1.182 +MAIN_DIALOG=${MAIN_DIALOG}"
   1.183 +			<hbox>
   1.184 +				<button>
   1.185 +					<label>Burn disk</label>
   1.186 +					<input file icon=\"forward\"></input>
   1.187 +					<action>$0 burn_iso</action>
   1.188 +				</button>
   1.189 +			</hbox>"
   1.190 +MAIN_DIALOG=${MAIN_DIALOG}'
   1.191 +		</frame>
   1.192 +		
   1.193 +	</vbox>
   1.194 +	<vbox>	
   1.195 +		<tree icon_name="audio-x-generic">
   1.196 +			<width>500</width><height>200</height>
   1.197 +			<variable>TRACKS_LIST</variable>
   1.198 +			<label>Track name</label>
   1.199 +			<input>ls -1 /tmp/audio-cd</input>
   1.200 +			<action>rm "/tmp/audio-cd/$TRACKS_LIST"</action>
   1.201 +			<action>refresh:TRACKS_LIST</action>
   1.202 +			<action>refresh:TRACKS_SIZE</action>
   1.203 +		</tree>'
   1.204 +# Select, add and burn audio buttons.
   1.205 +MAIN_DIALOG=${MAIN_DIALOG}"
   1.206 +		<hbox>
   1.207 +			<text>
   1.208 +				<label>Title:   </label>
   1.209 +			</text>
   1.210 +			<entry accept=\"filename\">
   1.211 +				<label>Select an Audio track</label>
   1.212 +				<variable>NEW_TRACK</variable>
   1.213 +			</entry>
   1.214 +			<button>
   1.215 +				<input file stock=\"gtk-open\"></input>
   1.216 +				<action type=\"fileselect\">NEW_TRACK</action>
   1.217 +			</button>
   1.218 +			<button>
   1.219 +				<label>Add</label>
   1.220 +				<input file stock=\"gtk-add\"></input>
   1.221 +				<action>$0 copy_audio_file</action>
   1.222 +				<action>refresh:TRACKS_LIST</action>
   1.223 +				<action>refresh:TRACKS_SIZE</action>
   1.224 +			</button>
   1.225 +		</hbox>
   1.226 +		<hbox>
   1.227 +			<text>
   1.228 +				<label>Album:</label>
   1.229 +			</text>
   1.230 +			<entry accept=\"directory\">
   1.231 +				<label>Select an Audio track</label>
   1.232 +				<variable>NEW_DIR</variable>
   1.233 +			</entry>
   1.234 +			<button>
   1.235 +				<input file stock=\"gtk-open\"></input>
   1.236 +				<action type=\"fileselect\">NEW_DIR</action>
   1.237 +			</button>
   1.238 +			<button>
   1.239 +				<label>Add</label>
   1.240 +				<input file stock=\"gtk-add\"></input>
   1.241 +				<action>$0 copy_audio_dir</action>
   1.242 +				<action>refresh:TRACKS_LIST</action>
   1.243 +				<action>refresh:TRACKS_SIZE</action>
   1.244 +			</button>
   1.245 +		</hbox>
   1.246 +		<hbox>
   1.247 +			<text>
   1.248 +				<variable>TRACKS_SIZE</variable>
   1.249 +				<input>$0 audio_cd_stats</input>
   1.250 +			</text>
   1.251 +			<button>
   1.252 +				<label>Clean</label>
   1.253 +				<input file stock=\"gtk-clear\"></input>
   1.254 +				<action>rm -rf /tmp/audio-cd/*</action>
   1.255 +				<action>refresh:TRACKS_LIST</action>
   1.256 +				<action>refresh:TRACKS_SIZE</action>
   1.257 +				<action>clear:NEW_TRACK</action>
   1.258 +				<action>clear:NEW_DIR</action>
   1.259 +			</button>
   1.260 +			<button>
   1.261 +				<label>Burn disk</label>
   1.262 +				<input file icon=\"forward\"></input>
   1.263 +				<action>$0 burn_audio</action>
   1.264 +			</button>
   1.265 +		</hbox>
   1.266 +	</vbox>"
   1.267 +export MAIN_DIALOG=${MAIN_DIALOG}'
   1.268 +	
   1.269 +	</notebook>
   1.270 +	
   1.271 +	<hbox>
   1.272 +		<button>
   1.273 +			<label>Exit</label>
   1.274 +			<input file icon="exit"></input>
   1.275 +			<action type="exit">Exit</action>
   1.276 +		</button>
   1.277 +	</hbox>
   1.278 +	
   1.279 +</vbox>
   1.280  </window>
   1.281  '
   1.282  
   1.283 -# We need at least device, speed and ISO image path.
   1.284 -#
   1.285 -export MOUNT_DIALOG='
   1.286 -<window title="Burnbox" icon-name="drive-optical">
   1.287 -  <vbox>
   1.288 -
   1.289 -    <text use-markup="true">
   1.290 -      <label>
   1.291 -"
   1.292 -<b>SliTaz - Burnbox</b>"
   1.293 -      </label>
   1.294 -    </text>
   1.295 -    <text wrap="true" width-chars="54" use-markup="true">
   1.296 -      <label>
   1.297 -"
   1.298 -Burn ISO images to CD or DVD writer using Wodim from cdrkit.
   1.299 -Please verify device write settings, add options if needed 
   1.300 -and select an ISO image file. You can erase CD-RW with
   1.301 -'blank=all' option. Note : You can manipulate  ISO images with
   1.302 -ISO Master utility.
   1.303 -"
   1.304 -      </label>
   1.305 -    </text>
   1.306 -  
   1.307 -    <frame Configuration>
   1.308 -      <hbox>
   1.309 -        <text use-markup="true">
   1.310 -          <label>"<b>Device     :</b>"</label>
   1.311 -        </text>
   1.312 -        <entry>
   1.313 -          <default>/dev/cdrom</default>
   1.314 -          <variable>DEVICE</variable>
   1.315 -        </entry>
   1.316 -      </hbox>
   1.317 -      <hbox>
   1.318 -        <text use-markup="true">
   1.319 -          <label>"<b>Speed     :</b>"</label>
   1.320 -        </text>
   1.321 -        <entry>
   1.322 -          <input>cat /proc/sys/dev/cdrom/info | grep "drive speed" | cut -f 3</input>
   1.323 -          <variable>SPEED</variable>
   1.324 -        </entry>
   1.325 -      </hbox>
   1.326 -      <hbox>
   1.327 -        <text use-markup="true">
   1.328 -          <label>"<b>Options  :</b>"</label>
   1.329 -        </text>
   1.330 -        <entry>
   1.331 -          <default>-eject -multi</default>
   1.332 -          <variable>OPTIONS</variable>
   1.333 -        </entry>
   1.334 -      </hbox>
   1.335 -    </frame>
   1.336 -   
   1.337 -    <frame ISO image>
   1.338 -      <hbox>
   1.339 -        <text use-markup="true">
   1.340 -          <label>"<b>File :</b>"</label>
   1.341 -        </text>
   1.342 -        <entry>
   1.343 -          <variable>ISO_IMAGE</variable>
   1.344 -        </entry>
   1.345 -        <button>
   1.346 -          <input file stock="gtk-cdrom"></input>
   1.347 -          <action type="fileselect">ISO_IMAGE</action>
   1.348 -        </button>
   1.349 -      </hbox>
   1.350 -    </frame>
   1.351 -    
   1.352 -    <hbox>
   1.353 -      <button>
   1.354 -        <input file icon="help"></input>
   1.355 -	<action>xterm -sb -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 95x25 -title "wodim help" -e "wodim --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
   1.356 -      </button>
   1.357 -      <button>
   1.358 -        <label>Burn</label>
   1.359 -        <input file icon="forward"></input>
   1.360 -        <action>echo "Burning $ISO_IMAGE..."</action>
   1.361 -        <action>gtkdialog --program=BURN_DIALOG</action>
   1.362 -      </button>
   1.363 -      <button>
   1.364 -        <input file icon="exit"></input>
   1.365 -        <action type="exit">Exit</action>
   1.366 -      </button>
   1.367 -    </hbox>
   1.368 -  
   1.369 -  </vbox>
   1.370 -</window>
   1.371 -'
   1.372 -
   1.373 -# Execute main dialog.
   1.374 -gtkdialog --program=MOUNT_DIALOG
   1.375 +# Script can be called with an arg to exec a function.
   1.376 +if [ -n "$1" ]; then
   1.377 +	$1
   1.378 +else
   1.379 +	mkdir -p /tmp/audio-cd
   1.380 +	gtkdialog --center --program=MAIN_DIALOG >/dev/null
   1.381 +	rm -rf /tmp/audio-cd
   1.382 +fi
   1.383  
   1.384  exit 0