slitaz-dev-tools diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/qemu-box/qemu-box	Thu May 03 09:53:49 2012 +0200
     1.3 @@ -0,0 +1,66 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# Small Qemu front end powered by Yad/GTK.
     1.7 +#
     1.8 +# Copyright (C) 2012 SliTaz GNU/Linux - BSD License
     1.9 +#
    1.10 +# Author: Christophe Lincoln <pankso@slitaz.org>
    1.11 +#
    1.12 +
    1.13 +# TODO: Handle vdisk image and kernel. Store virtual machine in $config
    1.14 +#config=$HOME/.config/qemu-box
    1.15 +
    1.16 +# Common boxes options.
    1.17 +opts=" --height=240 --width=500 --image=computer --image-on-top"
    1.18 +title="Qemu Box"
    1.19 +
    1.20 +# Main GUI box function with pure Yad spec
    1.21 +qemubox_main() {
    1.22 +	yad --form $opts --window-icon=computer \
    1.23 +		--text="<b>$title</b> - A Small Qemulator Helper" \
    1.24 +		--title="$title" \
    1.25 +		--field="$(gettext "ISO Image:")":FL \
    1.26 +		--field="$(gettext "Memory:")":NUM \
    1.27 +		--field="$(gettext "Options:")" \
    1.28 +		--button="Emulate":0 \
    1.29 +		--button="gtk-close":1 \
    1.30 +		" " "512" ""
    1.31 +}
    1.32 +
    1.33 +# Main function
    1.34 +qemubox() {
    1.35 +	# Store box results
    1.36 +	main=$(qemubox_main)
    1.37 +
    1.38 +	# Deal with --button values
    1.39 +	case $? in
    1.40 +		0) continue ;;
    1.41 +		*) exit 0 ;;
    1.42 +	esac
    1.43 +
    1.44 +	# Deal with $main values. File can be: .iso or vdisk .img
    1.45 +	file=$(echo $main | cut -d "|" -f 1)
    1.46 +	mem=$(echo $main | cut -d "|" -f 2 | cut -d "," -f 1)
    1.47 +	opts=$(echo $main | cut -d "|" -f 3)
    1.48 +
    1.49 +	case $file in
    1.50 +		*.iso) exec qemu -m $mem $opts -cdrom $file & ;;
    1.51 +		*.img) echo "TODO" ;;
    1.52 +		*) yad $opts --title="$title Error" \
    1.53 +			--text "<b>$title Error</b> $file" ;;
    1.54 +	esac
    1.55 +}
    1.56 +
    1.57 +#
    1.58 +# Script commands
    1.59 +#
    1.60 +
    1.61 +case "$1" in
    1.62 +	usage)
    1.63 +		echo "Usage: $(basename $0) [command]" ;;
    1.64 +	*)
    1.65 +		qemubox ;;
    1.66 +esac
    1.67 +
    1.68 +exit 0
    1.69 +