An example of a bash/yad script that I made by modifying my original bash/zenity one.

1,376 views
Skip to first unread message

Tony B

unread,
Mar 18, 2011, 1:27:23 PM3/18/11
to yad-c...@googlegroups.com
The following is a rewrite from zenity of my usb startup disk tool that is included in Remastersys for Debian Squeeze.

-------begin code-------
#!/bin/bash

#Copy to USB Key Tool Copyright 2009,2011 by Tony Brijeski under the GPL V2
#Using yad for gui calls

DIALOG="`which yad`"
TITLE="--always-print-result --dialog-sep --image=/usr/share/icons/
remastersys.png --title="
TITLETEXT="Remastersys USB Startup Disk Tool"
TEXT="--text="
ENTRY="--entry "
ENTRYTEXT="--entry-text "
FILESELECTION="--file-selection "
MENU="--list --column=Pick --column=Info"
PASSWORD="--entry --hide-text "


testroot="`whoami`"

if [ "$testroot" != "root" ]; then
remsu $0 &
exit
fi

copymenu () {
if [ "$1" = "(null)" ]; then
  $DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nYou must select a usb key to use.  Click OK to return to main menu.\n"
mainmenu
fi
if [ "$2" = "(null)" ]; then
  $DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nYou must select a source to use.  Click OK to return to main menu.\n"
mainmenu
fi

$DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nThis will completely replace the contents of your usb drive with the Bootable Live System.\n\nYou will not be able to undo this operation once it starts.\n\nClick OK to continue?\n"

if [ $? != 0 ]; then
mainmenu
fi

umount `mount | grep $1 | awk '{print $1}'`

progressbar "Copying to USB Key Now \n\nPlease Wait \n" &
#do the copy
dd if=$2 of=/dev/$1 bs=1M
sync
killall -KILL tail

  $DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nCopy to USB key completed. \nClick OK to return to main menu.\n"
mainmenu
}


progressbar () {
tail -f $0 | $DIALOG $TITLE"$TITLETEXT" $TEXT"$@" --progress --pulsate --auto-close
}

mainmenu () {
DEVS=""
DEVS=`ls -l /dev/disk/by-path/*usb* | grep -v "part" | awk '{print $NF}' | awk -F "/" '{print $NF}'`
if [ "$DEVS" != "" ]; then
for i in $DEVS; do
USBDRIVESIZE=`grep -m 1 "$i" /proc/partitions | awk '{print $3}'`
USBDRIVES="$USBDRIVES!$i-$USBDRIVESIZE"
done
else
  $DIALOG $TITLE"$TITLETEXT" $TEXT"\n\nNo USB Keys found.\n\n\nPlease insert a USB Key and then\nclick OK to return to main menu\nor Cancel to quit.\n"
if [ "$?" = "0" ]; then
mainmenu
else
exit
fi
fi

CHOICES=`$DIALOG $TITLE"$TITLETEXT" --form --field="USB Key:CB" $USBDRIVES --field="Source Image:FL" --button="Quit:2" --button="Copy to USB Key:1"`
retval="$?"

if [ "$retval" = "1" ]; then
USBDRIVE=`echo $CHOICES | cut -d "|" -f 1 | cut -d "-" -f 1`
PICKSOURCE=`echo $CHOICES | cut -d "|" -f 2`
copymenu $USBDRIVE $PICKSOURCE
else
exit
fi
}

mainmenu
-------end code-------

I just found yad yesterday and modifed my zenity/bash based script to the one above.  This one is smaller and better.

I will be rewriting all of my tools including the gui installer for debian squeeze with yad instead of zenity.

Regards,
Tony
http://www.remastersys.com

Victor Ananjevsky

unread,
Mar 19, 2011, 2:06:50 AM3/19/11
to yad-c...@googlegroups.com

thank you. i place yous script on wiki - http://code.google.com/p/yad/wiki/USBStartupDisk


--
Victor Ananjevsky <anan...@gmail.com>

Slavko

unread,
Mar 19, 2011, 12:59:20 PM3/19/11
to yad-c...@googlegroups.com
Ahoj,

Dňa Sat, 19 Mar 2011 08:06:50 +0200 Victor Ananjevsky
<anan...@gmail.com> napísal:

>
> thank you. i place yous script on wiki -
> http://code.google.com/p/yad/wiki/USBStartupDisk

can you send notice here, after it will be added, to i can to add it to
deb packages too?

--
s pozdravom

Slavko
http://slavino.sk

signature.asc

Tony B

unread,
Mar 19, 2011, 6:59:36 PM3/19/11
to yad-c...@googlegroups.com
When I get some time after rewriting my remastersys tools and installer with yad I will put together a howto.

Victor - I would also like to offer you some space on my forum if you are interested.  I already host my remastersys tool forum there and the AVLinux Distribution forum which is made by my fellow admin Gmaq.  If you are interested just sign up on my forum and let me know.  I'll add you to the forum Moderation team as well.

Yad needs more exposure as it is, in my opinion, the best gui toolset for bash.  I have looked for alternatives to zenity for a long time and I finally found yad.

Slavko - was your question intended for Victor or me?

regards,
Tony

Victor Ananjevsky

unread,
Mar 21, 2011, 2:21:57 AM3/21/11
to yad-c...@googlegroups.com
On Sat, 19 Mar 2011 18:59:36 -0400
Tony B <tb6...@gmail.com> wrote:

> When I get some time after rewriting my remastersys tools and installer with
> yad I will put together a howto.
>
> Victor - I would also like to offer you some space on my forum if you are
> interested. I already host my remastersys tool forum there and the AVLinux
> Distribution forum which is made by my fellow admin Gmaq. If you are
> interested just sign up on my forum and let me know. I'll add you to the
> forum Moderation team as well.
>
> Yad needs more exposure as it is, in my opinion, the best gui toolset for
> bash. I have looked for alternatives to zenity for a long time and I
> finally found yad.
>

yes, i agree, but i'm too lazy for promote yad more aggressively

> Slavko - was your question intended for Victor or me?
>
> regards,
> Tony
>
>
> On Sat, Mar 19, 2011 at 12:59 PM, Slavko <sla...@slavino.sk> wrote:
>
> > Ahoj,
> >
> > Dňa Sat, 19 Mar 2011 08:06:50 +0200 Victor Ananjevsky
> > <anan...@gmail.com> napísal:
> >
> > >
> > > thank you. i place yous script on wiki -
> > > http://code.google.com/p/yad/wiki/USBStartupDisk
> >
> > can you send notice here, after it will be added, to i can to add it to
> > deb packages too?
> >
> > --
> > s pozdravom
> >
> > Slavko
> > http://slavino.sk
> >


--
Victor Ananjevsky <anan...@gmail.com>

Reply all
Reply to author
Forward
0 new messages