VSIDO Community

VSIDO Support => Scripts and How To's => Zenity & Yad => Topic started by: statmonkey on September 26, 2013, 06:56:03 PM

Title: makethumb - Zenity script for burning images to USB
Post by: statmonkey on September 26, 2013, 06:56:03 PM
Not sure if there will be any interest in this but I have over time collected or put together quite a few zenity (and yad for that matter) scripts.  I thought that we might start something on the order of the bash aliases and collect a few of these that would help people have an idea of how to use them, or inspire some new creation, etc.  If their is interest I will post some of my yad scripts but I think zenity is probably more in regular use and after all there is very little top level difference between the two.

Post any scripts you like, loathe, etc. here.  I would love to see your work and good and bad I think it is how I learn best.
Title: Re: Vsido Zenity Collection
Post by: VastOne on September 27, 2013, 02:03:19 AM
^ Yes... I am most interested in this thread and will get to them when I can...

Thanks for sharing statmonkey!
Title: Re: Vsido Zenity Collection
Post by: Digit on September 27, 2013, 07:54:02 AM
me too!   VERY interested.

one of those things i'm itching to go play with, but just so many other things with their own momentum in the way first.

thnx loads for this thread.  :)
Title: A little method of burning an iso
Post by: statmonkey on September 29, 2013, 07:49:43 PM
I have been meaning to get back to this for some time.  I am triple posting here I guess which is dubious but hope to stir some contributions here.  The following script is something I threw together some time ago to see if I could.  Then as I was doing it wondered more if I should. :) Anyway, I like it as an example because it embraces quite a broad brush of what you can do with zen and uses various (although not close to all) of what zenity can do.  I realized that I really don't have a thread where I got all this or learned zenity.  I have just done all this hit and miss and I am sure that probably shows.

See Attachment later in thread
 
What is happening here?  Well the script will assume you have put a thumb in the drive but if not you can bail.  It will first check to see what you have mounted, then offer a short list of those mounts for you to grab the /dev location.  Then ask you to enter it.  It will then ask you to select your iso, confirm that you really want to do it.  Burn the thumb and offer you the opp to boot and see what you have done.

One of the things this thread and my self-posting is reminding me is that with zenity I usually use it for little routine things that I want a quick and dirty for.  I write them and then forget them (as in never edit or fix little gotcha's)  I think it psychologically makes it seem finished even if it isn't.  I hope that makes sense.  Anyway, I really need to add to my todo to go through all my zenity scripts and clean them up.  So even if no one else gets anything out of my assorted crap I guess I win.  ::)
Title: Re: Vsido Zenity Collection
Post by: VastOne on September 29, 2013, 07:54:25 PM
Hey ZenMan...  8)

I have been a bit busy getting the ISO trimmed and healthy, but now that this is done I can devote some more time to this and I will...

I am also known as a hibernating developer, the colder it gets, the more code I look at and work on..

Have patience and I will get on board with this...
Title: Re: Vsido Zenity Collection
Post by: PackRat on September 30, 2013, 01:49:22 PM
@statmonkey

nice script to burn iso's - just used it to burn the latest vsido iso to usb.
Title: Re: Vsido Zenity Collection
Post by: statmonkey on September 30, 2013, 06:34:32 PM
What!? It works? .... just kidding.  Glad you found it useful.
Title: Re: Vsido Zenity Collection
Post by: statmonkey on November 11, 2013, 07:49:16 AM
You know if I keep double posting like this I will have to report myself. :)

I have updated the make a thumb script quite a bit.  I wanted to learn how to use an array in a zenity script, I had trouble with this the first time which is why the script makes the user input the first three letters of the drive.  I really wanted the documentation to be such that anyone who picked it up could follow along and see exactly what is going on.  The idea being if there was anyone stumbling in here who wanted an idea of how to do some things in zenity this would serve the purpose but at the same time be a functional script that had some value.  Here's a summary of the updates:
Code: [Select]
# UPDATES: Adjusted to use an array rather than request user data entry.
#          Added some sanity check so the user can opt out
#          Added a section to clean up after completion.
#          Added a root sanity check
#          Added variable documentation so user can understand what is happening
#          Added progress bar that autocloses
#          Changed script to clean up after itself so it doesn't leave any cruft   

And I am attaching the script for anyone who wants it.  Just put it in your path and make it executable.  As long as you have bash, zenity, an iso you want to burn and a usb/thumb drive it will work.
Title: Re: Vsido Zenity Collection
Post by: VastOne on November 11, 2013, 02:14:32 PM
Morning statmonkey

I tried this this morning and wanted to let you know...

VSIDO does not have zenity installed by default, it will now...  :)

I am getting a devnull file created when I run this that shows

Code: [Select]
ls: cannot access /dev/disk/by-path/*usb*part*: No such file or directory
and a blank list of 'Select items from the list'

Heading out for the day... will see you later on tonight
Title: Re: Vsido Zenity Collection
Post by: statmonkey on November 11, 2013, 05:43:40 PM
Hmm curious.  I just downloaded to a couple of different machines and it ran with no issues.  I now have several thumbs of mrneilypops.dwmX Iso.   :D

Obviously the devnull should be empty, it does nothing but acts as a conduit for the variable.
Code: [Select]
devs=`ls -al /dev/disk/by-path/*usb*part* 2>\dev\null | awk '{print($11)}'`
all this line of code is doing is passing as a string, the contents of the folder /dev/disk/by-path and filtering on usb and part.  Which is essentially the same command you would run by hand.  There is nothing unique there its just using a variable, ls, awk and print. 

It will fail as a general rule on only two occasions. First if you aren't root it will give you a permission denied. The second is slightly more complicated but if you have no usb drives mounted or the thumb inserted is mounted read-only.  This would explain why the list is empty.

I have been having issues with spacefm (both the daemon and spacefm itself) insisting that any thumb be mounted ro and not allowing the root user to mount it any other way.  Actually have been having quite a few issues with spacefm of late and am now back using thunar. That's another story.  Regardless can you check and see if this is the case. If the thumb is mounted ro then nothing is going to write to it.  If that's the case you'll have to unmount the thumb, kill spacefm and it's daemon if you are running it and mount the thumb rw. I rewrote the options for udevil several times but spacefm keeps overwriting them so I gave up.  It apparently thinks rw 9660 drives are evil. Actually I think this is a consequence of the way systemd is handling the drives and udevil doesn't like that. But that's speculation on my part.

Also in this thread is the original makethumb which we know works (I think Jed and packrat have used it) you could use that as a quick test as well and if it won't run then it is specific to your system. 

Also if anyone else could test this and see if they get the same results it would be a big help.

Note: Have to laugh if my failing script finally gets you on the zenity train :)
Title: Re: Vsido Zenity Collection
Post by: VastOne on November 11, 2013, 11:35:09 PM
Well, now I did just wake up... and maybe I do need to read it again, but I missed where it was an absolute need to have a usb mounted...  ::)  :P  :-*

(DOH what a dumb ass I was this morning)

It works perfectly with a usb mounted

Great job!
Title: Re: Vsido Zenity Collection
Post by: jedi on November 12, 2013, 04:12:18 AM
Yes this nice little jewel of a script works great when you plug-in a USB drive first!  Just used it a couple of days ago to burn an ISO.  It even burns "non-VSIDO" ISO's!   :D :D :D
Title: Re: Vsido Zenity Collection
Post by: statmonkey on November 12, 2013, 06:07:30 AM
VastOne.  Nope, not on you.  I think the documentation was a little unclear.  I made it clearer, I hope, added to the documentation so it should be clearer see attached.

Jedi - I thank you.  I think this version is quite an improvement.  Getting zenity to see and use the array removes the user data entry step of  the drive letters.  This reduces risk of screwing up and I think makes the whole process smoother.

What do you mean?  Are there other iso's besides Vsido you would burn? :)
Title: Re: Vsido Zenity Collection
Post by: PackRat on November 13, 2013, 02:25:36 AM
Just used this to burn the latest vsido iso; just confirming that the script works with yad (on slackware) installed. Just had to make a symlink zenity to yad.
Title: Re: Vsido Zenity Collection
Post by: VastOne on November 13, 2013, 02:30:27 AM
^ Now that is slick thinking... well done PackRat   8)

Where and what was the symlink for those that may inquire?
Title: Re: Vsido Zenity Collection
Post by: VastOne on November 13, 2013, 02:32:53 AM
@ statmonkey,

Your makethumbv2.1 file is a 0 byte file..  Did a wire get crossed?
Title: Re: Vsido Zenity Collection
Post by: PackRat on November 13, 2013, 02:47:06 AM
yad is a fork of zenity for those that haven't heard of it - I think zenity went a while without a maintainer so someone forked it.

The default SlackBuild installs yad to /usr/bin so a simple -

Code: [Select]
sudo ln -s /usr/bin/yad /usr/bin/zenity
does the trick.

As far as I know, the two are nearly 100% compatable.
Title: Re: Vsido Zenity Collection
Post by: VastOne on November 13, 2013, 02:49:06 AM
^ Thanks!  8)
Title: Re: Vsido Zenity Collection
Post by: statmonkey on November 13, 2013, 02:52:16 AM
No, that was not intentional.  That took forever to upload not sure why it didn't work. Anyway it's all good, it gives me a chance to write in a little sanity check for VastOne that will make sure you have a USB mounted otherwise it will exit.  I had missed that because I usually have 4 or 5 external drives mounted whenever I am working, so it was always going to see a usb of some type.  I just overlooked the fact that I am not "normal". No, Digit no need for you to comment. :)

Packrat that is brilliant, I never thought of that.  I used to write everything in yad and then when I was using CB no one else was using it so went back to zenity.  Slavinko forked it from zenity due to some inefficiencies in zenity that weren't being addressed back in the day.  I am pretty sure that there are only middling differences in coding between the two now but haven't looked lately.  I do want to check those out again, thanks for the push.
Title: Re: Vsido Zenity Collection
Post by: VastOne on November 13, 2013, 03:08:26 AM
^ The USB check for dummies (VastOne guide) works perfectly...

I have a couple of suggestions to keep this in a more fluent work flow... let me know what any of you think

I think this will grow and more and more zenity and yad scripts will flow... My first suggestion is to create a child board just for that calling it VSIDO Zenity/Yad Collections under Scripts & How To's

From there have a separate thread for each new project started...

The second suggestion is to always go back with files that have been uploaded and keep each at the same level.  If you have uploaded for example vastone_is_dumb.sh and then create and upload vastone_is_dumbII.sh, make sure both links have the same file... this way a user will always get the same files no matter what. 

I would recommend even further that statmonkey and anyone creating scripts to start your own sourceforge or github account and then you would not only have a work flow where you could have all versions,  you would also then only have to provide a link for the files...

These are my thoughts... let me know what y'all think
Title: Re: Vsido Zenity Collection
Post by: statmonkey on November 13, 2013, 03:16:51 AM
All great suggestions, in fact have a couple more that I have been meaning to put up and was hesitating for that very reason - confused on where to put them.  If you or one of our helpful mods can move this great.  Definitely think separate threads are in order.

I was in the process of doing that very thing when I saw this post.  Already removed the empty 2.1. I will go through the dmenu thing and clean that up as well.

I have a sf for my work stuff so will look at github. My clients are rather s ends in d so I should probably not confuse them. :)
Title: Re: Vsido Zenity Collection
Post by: VastOne on November 13, 2013, 03:18:40 AM
^ I'll begin setting it up...

I prefer sourceforge myself... I like the projects mode there
Title: Re: makethumb - Zenity script for burning images to USB
Post by: VastOne on November 13, 2013, 04:15:25 PM
I have reorganized Script's and How To's

I have also upped the attachment sizes so that larger files can be uploaded
Title: Re: makethumb - Zenity script for burning images to USB
Post by: statmonkey on November 13, 2013, 09:45:50 PM
Nice job VastOne.  I do have some others I'll post in here. 

Additionally set up makethumb on sf available here https://sourceforge.net/projects/makethumb/ (https://sourceforge.net/projects/makethumb/)