tazusb view tazusb-box @ rev 199

Update path to kbd (backward compatible)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jun 28 09:20:53 2017 +0200 (2017-06-28)
parents 8ddffadf56a6
children
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 . /lib/libtaz.sh
13 # TazUSBbox is only for root.
15 if [ $(id -u) -ne 0 ]; then
16 exec tazbox su tazusb-box
17 exit 0
18 fi
21 # We can specify an ISO on cmdline: tazusb-box --iso=/path/to/image.iso
23 [ "$iso" ] || iso=" "
25 title='TazUSB Box'
26 icon='/usr/share/pixmaps/slitaz-icon.png'
27 opts="--window-icon=$icon --height=220 --width=520 --center --on-top"
30 # i18n
32 export TEXTDOMAIN='tazusb-box'
35 # Main text information
37 info="<b>$(_ 'Generate SliTaz LiveUSB media and boot in RAM!')</b>\n\n \
38 $(_ "Insert a LiveCD into the CD-ROM drive or use a local ISO image, select \
39 the correct device and press OK.")
40 "
43 #
44 # Functions
45 #
47 # Nice GTK output for commands.
49 output() {
50 yad --text-info $opts --title="$title" --tail --margins=4 \
51 --button="$(_n 'Reboot'):reboot" --button="gtk-close:0"
52 }
55 list_devices() {
56 if [ -d /proc/scsi/usb-storage ]; then
57 dev="$(blkid | cut -d: -f1)"
58 echo $dev | sed s'/ /!/'g
59 else
60 _ 'No USB media found'
61 fi
62 }
65 # Main GUI box function with pure Yad spec
67 usbbox_main() {
68 yad --form $opts --title="$title" --text="$info" \
69 --image=usb-creator --image-on-top \
70 --field="$(_n 'ISO Image:')":FL \
71 --field="$(_n 'USB Media:')":CB \
72 "$iso" "$(list_devices)"
73 }
76 # Handler
78 usbbox() {
79 # Store box results
80 main=$(usbbox_main)
82 # Deal with --button values
83 case $? in
84 1) exit 0 ;;
85 *) continue ;;
86 esac
88 # Deal with $main values. Exit if any device.
89 dev=$(echo $main | cut -d"|" -f2)
90 if ! echo $dev | grep -q /dev; then
91 _ 'No device: exit'
92 exit 0
93 fi
94 if echo "$main" | grep -q ".iso|"; then
95 iso=$(echo $main | cut -d "|" -f1)
96 yes '' | tazusb gen-iso2usb $iso $dev --output=raw | output
97 else
98 yes '' | tazusb gen-liveusb $dev --output=raw | output
99 fi
100 }
103 #
104 # Script commands
105 #
107 case "$1" in
108 usage|--help|-h)
109 echo "$(_ 'Usage:') $(basename $0) [list]" ;;
110 list)
111 list_devices ;;
112 *)
113 usbbox ;;
114 esac
116 exit 0