slitaz-tools diff boxes/burn-box @ rev 813
Current state, features stabilized and open for bugfixes and translations.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Sep 09 03:27:04 2013 +0300 (2013-09-09) |
parents | 463e0588d40d |
children | c79e656b37a5 |
line diff
1.1 --- a/boxes/burn-box Tue Jul 09 05:05:59 2013 +0000 1.2 +++ b/boxes/burn-box Mon Sep 09 03:27:04 2013 +0300 1.3 @@ -1,30 +1,27 @@ 1.4 #!/bin/sh 1.5 # 1.6 # Burn-box a small front end to cdrkit powered by Yad/GTK. Keep the main 1.7 -# window uncluttered and use a wizard to create audio/video/data cd/dvd. 1.8 +# window uncluttered and use a wizard to create audio/video/data CD/DVD. 1.9 # The main box lets users burn an ISO and audio files from a single directory. 1.10 # 1.11 -# Copyright (C) 2012 SliTaz GNU/Linux - BSD License 1.12 +# Copyright (C) 2012-2013 SliTaz GNU/Linux - BSD License 1.13 # 1.14 # Author: Christophe Lincoln <pankso@slitaz.org> 1.15 # 1.16 . /lib/libtaz.sh 1.17 +export TEXTDOMAIN='slitaz-boxes' # i18n 1.18 1.19 # LibTaz parser and store options. Burn-box can be used with an ISO image 1.20 # or an audio directory in option: burn-box --iso=/path/to/image.iso 1.21 [ "$iso" ] || iso=" " 1.22 [ "$audio" ] || audio="$HOME" 1.23 1.24 -# Internal variables (we need a space before options). 1.25 -boxopts="--height=300 --width=520 --window-icon=drive-cdrom" 1.26 -options=" -eject -multi" 1.27 -speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f 3) 1.28 -tmpdir=/tmp/$(basename $0) 1.29 - 1.30 -# Internationalization 1.31 -. /usr/bin/gettext.sh 1.32 -TEXTDOMAIN='slitaz-boxes' 1.33 -export TEXTDOMAIN 1.34 +# Internal variables 1.35 +boxopts="--height=300 --width=620" 1.36 +icon=media-optical-dvd-rw 1.37 +options="-eject -multi" 1.38 +speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) 1.39 +tmpdir=$(mktemp -d) 1.40 1.41 # 1.42 # Functions 1.43 @@ -32,38 +29,42 @@ 1.44 1.45 # Help and usage 1.46 usage() { 1.47 - cat << EOT 1.48 + newline; _ 'Burn-box a small front end to cdrkit powered by Yad/GTK.' 1.49 + newline; boldify $(_ 'Usage:') 1.50 + echo " $(basename $0) [$(_n 'command')|$(_n 'option')] [$(_n 'file')]" 1.51 1.52 -$(gettext "Usage:") $(basename $0) [command|option] [file] 1.53 + newline; boldify $(_ 'Commands:') 1.54 + optlist "\ 1.55 +wodim-help|-wh $(_n 'Show all Wodim options') 1.56 +iso|-i $(_n 'Burn an ISO image') 1.57 +audio|-a $(_n 'Create and burn an audio CD') 1.58 +blank $(_n 'Erase a RW disk')" 1.59 1.60 -$(gettext "Commands:") 1.61 - wodim-help|-wh $(gettext "Show all Wodim options") 1.62 - iso|-i $(gettext "Burn an ISO image") 1.63 - audio|-a $(gettext "Create and burn an audio CD") 1.64 + newline; boldify $(_ 'Options:') 1.65 + echo "\ 1.66 + --iso=$(_n '/path/to/image.iso') 1.67 + --audio=$(_n '/path/to/directory')" 1.68 1.69 -$(gettext "Options:") 1.70 - --iso=/path/to/image.iso 1.71 - --audio=/path/to/directory 1.72 - 1.73 -$(gettext "Examples:") 1.74 - $(basename $0) iso /path/to/image.iso 1.75 - $(basename $0) --iso=/path/to/image.iso 1.76 - 1.77 -EOT 1.78 + newline; boldify $(_ 'Examples:') 1.79 + echo "\ 1.80 + $(basename $0) iso $(_n '/path/to/image.iso') 1.81 + $(basename $0) --iso=$(_n '/path/to/image.iso')" 1.82 + newline 1.83 } 1.84 1.85 # Ouput a command to a Yad/GTK box. Usage: cmd | out --title="Title" --tail 1.86 gtkout() { 1.87 - yad --text-info $boxopts "$@" --margins=4 --button="gtk-close":1 1.88 + yad --window-icon=$icon $boxopts \ 1.89 + --margins=4 --fontname=monospace \ 1.90 + --text-info "$@" --button="gtk-close:1" 1.91 } 1.92 1.93 # Decode audio files with: decode [file] 1.94 decode_audio() { 1.95 - gettext "Decoding files from:"; echo " $audio" 1.96 - rm -rf $tmpdir && mkdir -p $tmpdir 1.97 + _ 'Decoding files from: $audio' 1.98 for f in "$audio"/*.* 1.99 do 1.100 - [ "$debug" ] && echo "DEBUG: handling $f" 1.101 + debug "handling $f" 1.102 case "$f" in 1.103 *.wav) 1.104 cp -f "$f" $tmpdir ;; 1.105 @@ -79,8 +80,9 @@ 1.106 1.107 # Burn an ISO image. 1.108 burn_iso() { 1.109 - [ "${iso##*.}" != "iso" ] && \ 1.110 - (gettext "Not an ISO image:"; echo " $iso") && exit 1 1.111 + if [ "${iso##*.}" != "iso" ]; then 1.112 + _ 'Not an ISO image: "$iso"'; exit 1 1.113 + fi 1.114 wodim -v speed=$speed $options "$iso" 1.115 } 1.116 1.117 @@ -95,19 +97,18 @@ 1.118 1.119 # Main GUI box function with pure Yad spec 1.120 burn_main() { 1.121 - text="$(gettext "Burn ISO images and audio files [data in next releases]")" 1.122 - yad --form $boxopts --title="Burn-box" \ 1.123 - --image=application-x-cd-image --image-on-top \ 1.124 - --text="<b>$text</b>" \ 1.125 - --field="$(gettext "Drive speed:")" \ 1.126 - --field="$(gettext "Wodim options:")" \ 1.127 - --field="$(gettext "ISO image:")":FL \ 1.128 - --field="$(gettext "Audio files:")":DIR \ 1.129 - --button="$(gettext "Wodim help")":"$0 wodim-help" \ 1.130 - --button="$(gettext "Blank CD")":"$0 blank" \ 1.131 - --button="$(gettext "Burn")":0 \ 1.132 - --button="gtk-close":1 \ 1.133 - "$speed" "$options" "$iso" "$audio" 1.134 + yad --title="$(_ 'Burn-box')" --window-icon=$icon $boxopts \ 1.135 + --image=$icon --image-on-top \ 1.136 + --text="<b>$(_n 'Burn ISO images and audio files [data in next releases]')</b>" \ 1.137 + --form \ 1.138 + --field="$(_n 'Drive speed:')" "$speed" \ 1.139 + --field="$(_n 'Wodim options:')" " $options" \ 1.140 + --field="$(_n 'ISO image:'):FL" "$iso" \ 1.141 + --field="$(_n 'Audio files:'):DIR" "$audio" \ 1.142 + --button="$(_n 'Wodim help'):$0 wodim-help" \ 1.143 + --button="$(_n 'Blank CD'):$0 blank" \ 1.144 + --button="$(_n 'Burn'):0" \ 1.145 + --button="gtk-close:1" 1.146 } 1.147 1.148 # Main function 1.149 @@ -121,20 +122,19 @@ 1.150 *) exit 0 ;; 1.151 esac 1.152 1.153 - # Get value from $main 1.154 - speed=$(echo $main | cut -d "|" -f 1 | cut -d "," -f 1) 1.155 - options=$(echo $main | cut -d "|" -f 2) 1.156 - iso=$(echo $main | cut -d "|" -f 3) 1.157 - audio=$(echo $main | cut -d "|" -f 4) 1.158 + # Get values from $main 1.159 + eval $(echo $main | awk -F'|' \ 1.160 + '{printf "speed=\"%s\" options=\"%s\" iso=\"%s\" audio=\"%s\"", $1, $2, $3, $4}') 1.161 + speed=${speed%%,*} # first from comma separated list 1.162 1.163 # Handle ISO image 1.164 if [ "$iso" != "(null)" ]; then 1.165 - burn_iso 2>&1 | gtkout --title="Burning ISO" --tail 1.166 + burn_iso 2>&1 | gtkout --title="$(_n 'Burning ISO')" --tail 1.167 fi 1.168 1.169 # Handle Audio files. 1.170 if [ "$audio" != "$HOME" ]; then 1.171 - burn_audio 2>&1 | gtkout --title="Burning Audio" --tail 1.172 + burn_audio 2>&1 | gtkout --title="$(_n 'Burning Audio')" --tail 1.173 fi 1.174 } 1.175 1.176 @@ -143,13 +143,15 @@ 1.177 # 1.178 1.179 case "$1" in 1.180 + -h|--help) 1.181 + usage ;; 1.182 wodim-help|-wh) 1.183 - wodim --help 2>&1 | gtkout --title="Wodim Help" ;; 1.184 + wodim --help 2>&1 | gtkout --title="$(_n 'Wodim Help')" ;; 1.185 iso|-i) 1.186 # Let burn an ISO from cmdline: burn-box -i /path/to/image.iso 1.187 [ "$iso" == " " ] && iso="$2" 1.188 if [ ! -f "$iso" ]; then 1.189 - gettext "Missing ISO image"; echo " $iso" && exit 1 1.190 + _ 'Missing ISO image "$iso"'; exit 1 1.191 fi 1.192 burn_iso ;; 1.193 audio|-a) 1.194 @@ -157,11 +159,11 @@ 1.195 [ "$2" ] && audio="$2" 1.196 [ "$audio" == "$HOME" ] && unset audio 1.197 if [ ! -d "$audio" ]; then 1.198 - gettext "Missing audio directory"; echo " $audio" && exit 1 1.199 + _ 'Missing audio directory "$audio"'; exit 1 1.200 fi 1.201 burn_audio ;; 1.202 blank) 1.203 - wodim -v -blank=fast 2>&1 | gtkout --title="Wodim Blank" --tail ;; 1.204 + wodim -v -blank=fast 2>&1 | gtkout --title="$(_n 'Blank disk')" --tail ;; 1.205 ""|--*) 1.206 burn ;; 1.207 *)