tazusb view tazusb-box @ rev 127
Small up to fr.po
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Apr 15 19:10:27 2012 +0200 (2012-04-15) |
parents | 781d1bb345cb |
children | 270c1f41a635 |
line source
1 #!/bin/sh
2 #
3 # Tiny GTK interface to SliTaz Live USB tool aka TazUSB.
4 #
5 # Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2
6 #
7 # Authors : Christophe Lincoln <pankso@slitaz.org>
8 #
10 # TazUSBbox is only for root.
11 if test $(id -u) != 0 ; then
12 exec tazbox su tazusb-box
13 exit 0
14 fi
16 title="TazUSB Box"
17 icon="usb-creator"
18 opts="--image=usb-creator --image-on-top --width=520 --center --on-top"
20 # I18n
21 . /usr/bin/gettext.sh
22 TEXTDOMAIN='tazusb-box'
23 export TEXTDOMAIN
25 # Main text information
26 info="$(gettext "<b>Generate SliTaz LiveUSB media and boot in RAM!</b> \
27 Insert a LiveCD into the cdrom drive or use a local ISO image, select \
28 the correct device and press OK.")
29 "
31 #
32 # Functions
33 #
35 # Nice GTK output for commands.
36 output() {
37 yad --text-info $opts --text="<b>$title</b>" \
38 --height=260 --title="$title" --window-icon=$icon \
39 --tail --margins=4 --button="Reboot:reboot" --button="gtk-close:0"
40 }
42 list_devices() {
43 if [ -d /proc/scsi/usb-storage ]; then
44 dev="$(blkid | cut -d ":" -f 1)"
45 echo $dev | sed s'/ /!/'g
46 else
47 gettext "No USB media found"
48 fi
49 }
51 # Main GUI box function with pure Yad spec
52 tazusb_main() {
53 yad --form $opts --text="$info" \
54 --title="$title" --height=200 \
55 --field="$(gettext "ISO Image:")":FL \
56 --field="$(gettext "USB Media:")":CB \
57 " " "$(list_devices)"
58 }
60 # Handler
61 tazusb() {
62 # Store box results
63 main=$(tazusb_main)
64 ret=$?
65 # Deal with --button values
66 case $ret in
67 1) exit 0 ;;
68 *) continue ;;
69 esac
70 # Deal with $main values. Exit if any device.
71 dev=$(echo $main | cut -d "|" -f 2)
72 if ! echo $dev | grep -q /dev; then
73 exit 0
74 fi
75 if echo "$main" | grep -q ".iso|"; then
76 iso=$(echo $main | cut -d "|" -f 1)
77 yes "" | /usr/bin/tazusb gen-iso2usb $iso $dev --raw-out | output
78 exit 0
79 else
80 yes "" | /usr/bin/tazusb gen-liveusb $dev --raw-out | output
81 fi
82 }
84 #
85 # Script commands
86 #
88 case "$1" in
89 usage)
90 echo "Usage: $(basename $0) [command]" ;;
91 *)
92 tazusb ;;
93 esac
95 exit 0