tazusb view tazusb-box @ rev 110

Add new tazusb-box using Yad
author Christophe Lincoln <pankso@slitaz.org>
date Fri Mar 02 19:12:53 2012 +0100 (2012-03-02)
parents
children a5f5b6aad358
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 tazusbbox
13 exit 0
14 fi
16 # I18n
17 . /usr/bin/gettext.sh
18 TEXTDOMAIN='tazusb-box'
19 export TEXTDOMAIN
21 info="$(gettext "<b>Generate SliTaz LiveUSB media and boot in RAM!</b> \
22 Insert a LiveCD into the cdrom drive or use a local ISO image, select \
23 the correct device and press OK.")
24 "
26 #
27 # Functions
28 #
30 gen_live()
31 {
32 [ -z "$DEVICE" ] && exit 0
33 if [ -n "$ISO_IMAGE" ]; then
34 xterm -T "Tazusb gen-iso2usb" \
35 -geometry 80x16 \
36 -e "tazusb gen-iso2usb $ISO_IMAGE $DEVICE; exit 0"
37 else
38 xterm -T "Tazusb gen-liveusb" \
39 -geometry 80x16 \
40 -e "tazusb gen-liveusb $DEVICE; exit 0"
41 fi
42 }
44 list_devices() {
45 if [ -d /proc/scsi/usb-storage ]; then
46 dev="$(blkid | cut -d ":" -f 1)"
47 echo $dev | sed s'/ /!/'g
48 else
49 gettext "No USB media found"
50 fi
51 }
53 # Main GUI box function with pure Yad spec
54 tazusb_main() {
55 yad --form --text="$info" --title="TazUSB Box" \
56 --height=200 --width=500 --borders=4 \
57 --image=usb-creator --image-on-top \
58 --window-icon=usb-creator \
59 --field="$(gettext "ISO Image:")":FL \
60 --field="$(gettext "USB Media:")":CB \
61 " " "$(list_devices)"
62 }
64 # Handler
65 tazusb() {
66 # Store box results
67 main=$(tazusb_main)
68 ret=$?
69 # Deal with --button values
70 case $ret in
71 1) exit 0 ;;
72 *) continue ;;
73 esac
74 # Deal with $main values. Exit if any device.
75 dev=$(echo $main | cut -d "|" -f 2)
76 if ! echo $dev | grep -q /dev; then
77 exit 0
78 fi
79 if echo "$main" | grep -q ".iso|"; then
80 iso=$(echo $main | cut -d "|" -f 1)
81 terminal -T "Tazusb gen-iso2usb" \
82 -geometry 80x16 \
83 -e "tazusb gen-iso2usb $iso $dev; sleep 4; exit 0"
84 else
85 terminal -T "Tazusb gen-liveusb" \
86 -geometry 80x16 \
87 -e "tazusb gen-liveusb $dev; sleep 4; exit 0"
88 fi
89 }
91 #
92 # Script commands
93 #
95 case "$1" in
96 usage)
97 echo "Usage: $(basename $0) [command]" ;;
98 *)
99 tazusb ;;
100 esac
102 exit 0