slitaz-dev-tools view qemu-box/qemu-box @ rev 178

Add: qemu-box (small frontend to Qemu)
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 03 09:53:49 2012 +0200 (2012-05-03)
parents
children
line source
1 #!/bin/sh
2 #
3 # Small Qemu front end powered by Yad/GTK.
4 #
5 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
6 #
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
10 # TODO: Handle vdisk image and kernel. Store virtual machine in $config
11 #config=$HOME/.config/qemu-box
13 # Common boxes options.
14 opts=" --height=240 --width=500 --image=computer --image-on-top"
15 title="Qemu Box"
17 # Main GUI box function with pure Yad spec
18 qemubox_main() {
19 yad --form $opts --window-icon=computer \
20 --text="<b>$title</b> - A Small Qemulator Helper" \
21 --title="$title" \
22 --field="$(gettext "ISO Image:")":FL \
23 --field="$(gettext "Memory:")":NUM \
24 --field="$(gettext "Options:")" \
25 --button="Emulate":0 \
26 --button="gtk-close":1 \
27 " " "512" ""
28 }
30 # Main function
31 qemubox() {
32 # Store box results
33 main=$(qemubox_main)
35 # Deal with --button values
36 case $? in
37 0) continue ;;
38 *) exit 0 ;;
39 esac
41 # Deal with $main values. File can be: .iso or vdisk .img
42 file=$(echo $main | cut -d "|" -f 1)
43 mem=$(echo $main | cut -d "|" -f 2 | cut -d "," -f 1)
44 opts=$(echo $main | cut -d "|" -f 3)
46 case $file in
47 *.iso) exec qemu -m $mem $opts -cdrom $file & ;;
48 *.img) echo "TODO" ;;
49 *) yad $opts --title="$title Error" \
50 --text "<b>$title Error</b> $file" ;;
51 esac
52 }
54 #
55 # Script commands
56 #
58 case "$1" in
59 usage)
60 echo "Usage: $(basename $0) [command]" ;;
61 *)
62 qemubox ;;
63 esac
65 exit 0