script generators

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
learnhow2code

script generators

#1 Post by learnhow2code »

creates a script in /usr/local/bin named yadless, which is a graphical version of less:

Code: Select all

echo -e '#!/bin/bash\n#### license: creative commons cc0 1.0 (public domain)\n#### http://creativecommons.org/publicdomain/zero/1.0/\nyad --text-info --editable --wrap  --fontname=monospace --show-uri --listen' > /usr/local/bin/yadless ; chmod  +x /usr/local/bin/yadless
to use:

Code: Select all

find /usr/share | yadless
Last edited by learnhow2code on Tue 26 Jul 2016, 16:02, edited 2 times in total.

april

#2 Post by april »

My Puppy Precise 5.7.1 does not have the option --maximized or in fact many of the options in the script ?
It creates the script OK but will not run.

Code: Select all

#!/bin/bash
#### license: creative commons cc0 1.0 (public domain)
#### http://creativecommons.org/publicdomain/zero/1.0/
yad --text-info --editable --wrap  --fontname=monospace --show-uri --maximized --listen

Code: Select all

# find /usr/share | yadless
Unable parse command line: Unknown option --maximized
# yad --help
Usage:
  yad [OPTION...] Yet another dialoging program

Help Options:
  -h, --help                                     Show help options
  --help-all                                     Show all help options
  --help-general                                 Show general options
  --help-calendar                                Show calendar options
  --help-color                                   Show color selection options
  --help-dnd                                     Show drag-n-drop options
  --help-entry                                   Show text entry options
  --help-file                                    Show file selection options
  --help-font                                    Show font selection options
  --help-form                                    Show form options
  --help-icons                                   Show icons box options
  --help-list                                    Show list options
  --help-notification                            Show notification icon options
  --help-progress                                Show progress options
  --help-scale                                   Show scale options
  --help-text                                    Show text information options
  --help-misc                                    Show miscellaneous options
  --help-gtk                                     Show GTK+ Options

Application Options:
  --calendar                                     Display calendar dialog
  --color                                        Display color selection dialog
  --color-selection                              Alias for --color
  --dnd                                          Display drag-n-drop box
  --entry                                        Display text entry or combo-box dialog
  --file                                         Display file selection dialog
  --file-selection                               Alias for --file
  --font                                         Display font selection dialog
  --font-selection                               Alias for --font
  --form                                         Display form dialog
  --icons                                        Display icons box dialog
  --list                                         Display list dialog
  --notification                                 Display notification
  --progress                                     Display progress indication dialog
  --scale                                        Display scale dialog
  --text-info                                    Display text information dialog
  --display=DISPLAY                              X display to use

# 

learnhow2code

#3 Post by learnhow2code »

april wrote:My Puppy Precise 5.7.1 does not have the option --maximized or in fact many of the options in the script ?
thats good to know. this runs in puppy tahr.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#4 Post by MochiMoppel »

april wrote:My Puppy Precise 5.7.1 does not have the option --maximized or in fact many of the options in the script ?
Your Puppy Precise 5.7.1 uses a very old yad version (0.12.4). The --maximized option is not implemented yet, but all other options exist. Remove --maximized from the script and the script should run.

This brings up 2 other questions:
Why should it run maximized anyway?
And what does the resulting yad dialog has to do with less?

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Re: script generators

#5 Post by musher0 »

learnhow2code wrote:creates a script in /usr/local/bin named yadless, which is a graphical version of less:

Code: Select all

echo -e '#!/bin/bash\n#### license: creative commons cc0 1.0 (public domain)\n#### http://creativecommons.org/publicdomain/zero/1.0/\nyad --text-info --editable --wrap  --fontname=monospace --show-uri --maximized --listen' > /usr/local/bin/yadless ; chmod  +x /usr/local/bin/yadless
to use:

Code: Select all

find /usr/share | yadless
Hi, learnhow2code.

A couple of questions:

-- Which less does this patch apply to? The busybox one or the real one by
greenwood software?

-- How does one get back to the normal less if one does not like your patch?

-- Does your patch or script interfere with normal parameter usage in less?
(It is very important that it doesn't, IMO.)

-- Any screen shots of your patch in action, please? So we can see how different
it is from the regular less?

-- Care to explain what each parameter in your line does?

-- What is the logic behind your

Code: Select all

find /usr/share | yadless
code? Would that not trawl every single file in /usr/share to your middleman
yadless script?

-- Finally, why is your middleman script needed in the first place? Just because you
could or because someone expressed a genuine need? I believe that the real less
is quite complete in and of itself. So why your middleman script? What advantage
does it offer the user over the regular less?

Thanks in advance for any answers.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

learnhow2code

Re: script generators

#6 Post by learnhow2code »

apologies-- it looks like the version of yad in puppy tahr does NOT support --maxmized, removing that option makes the script work.

alternatively, you can upgrade yad in tahr (and save the old yad to /usr/bin/oldyad) with this one-liner:

Code: Select all

mkdir yad && cd yad && wget http://distro.ibiblio.org/refracta/files/extra_packages/yad_0.26.1-1_i386.deb ; dpkg-deb -x yad_0.26.1-1_i386.deb . ; mv /usr/bin/yad /usr/bin/oldyad ; cp usr/bin/yad /usr/bin
musher0 wrote:-- Which less does this patch apply to? The busybox one or the real one by
greenwood software?
neither. its not a patch, its a graphical version of less (its missing some features, includes the basics-- pipe text to the program.) im not suggesting that anyone use it unless they want to pipe text to a graphical window for paging.
-- How does one get back to the normal less if one does not like your patch?
use the less command instead of yadless, as usual.
-- Does your patch or script interfere with normal parameter usage in less?
(It is very important that it doesn't, IMO.)
its not full-featured, but it is a completely separate program with a different name. no interference. it doesnt have support of raw (i actually suggested a graphical less tool to a guy that coded it in pygtk once, who decided to include raw support.)
-- Care to explain what each parameter in your line does?
listing in the screencap.
-- What is the logic behind your

Code: Select all

find /usr/share | yadless
code? Would that not trawl every single file in /usr/share to your middleman
yadless script?
its a demo of piping something to yadless.
-- Finally, why is your middleman script needed in the first place? Just because you
could or because someone expressed a genuine need? I believe that the real less
is quite complete in and of itself.
i agree. this is slightly different-- not a replacement, or a middleman, a graphical alternative. im quite fond of the "real" version. this is a trick with yad.
So why your middleman script? What advantage
does it offer the user over the regular less?
interesting that people assumed this goes between you and less, rather than being a tool used on its own.

"less" is a pager, like "more." this is a graphical pager. sometimes i use leafpad for this:

find /usr/share | leafpad # works sometimes
Thanks in advance for any answers.
youre welcome, let me know if you have others.
Attachments
screencap.png
(69.73 KiB) Downloaded 190 times

april

#7 Post by april »

this runs in puppy tahr.thats good to know.
Perhaps you should put that in the heading?
Its a bit of a whacko post otherwise.

april

#8 Post by april »

MochiMoppel wrote:Your Puppy Precise 5.7.1 uses a very old yad version (0.12.4). The --maximized option is not implemented yet, but all other options exist. Remove --maximized from the script and the script should run.
Indeed it does thanks.

This brings up another question:

This will list a directorys contents in a window but of what practical use is that to me? I have Rox filer for such work with much more detail given by rox filer

learnhow2code

#9 Post by learnhow2code »

april wrote:This will list a directorys contents in a window but of what practical use is that to me? I have Rox filer for such work with much more detail given by rox filer
less will display text and let you page through it but what use is that to you? yadless isnt to list files... its to page through text. you can also use leafpad for that, but i think yad will have a longer wait before it stops updating.

there are probably other graphical less tools, this is just a cheap one using yad. its slow on long input, too. i piped the source of pmount into it, that took a minute.

but if you have no use for less, you will have even less use for yadless.

i removed the --maximized option for more compatibility. i think its better with it, but being able to actually run the script is a plus, too.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#10 Post by MochiMoppel »

april wrote:This will list a directorys contents in a window but of what practical use is that to me? I have Rox filer for such work with much more detail given by rox filer
This will list a directory's content and the content of all its subdirectories in a window. How would you do that with Rox?

But that's not the point here. The point is long text output in a terminal. When you open a console and type fInd /usr/share you will see that the output scrolls too quickly to read until it reaches the last line. Going back to read from the start is cumbersome. That's why commands like more or the more powerful less were invented. Try fInd /usr/share | more.

Tools like more or less make only sense in consoles. Every X window based editor or text viewer works like more/less by default. If you load long texts into any editor your will see the start of the text and will have to page down to the end, not the other way round as in a console.

And that's exactly why I fail to understand what this thread has to do with less and - even more puzzling - why it is titled "script generators".
learnhow2code wrote:there are probably other graphical less tools, this is just a cheap one using yad. its slow on long input, too.
Yes, it's very slow, which makes it even more questionable why you want to use it and why you add options that have no effect (e.g. --listen) .
Keep it simple: find /usr/share | yad --text-info

For a (speed) comparison here some examples. First the "original", lastly yad. The script will run the windows one by one.

Code: Select all

#! /bin/bash
urxvt -e bash -c "find /usr/share | less"
find /usr/share | leafpad
find /usr/share | gxmessage            -geometry 600x400 -file -        
find /usr/share | Xdialog --editbox            - 600x400
find /usr/share | yad     --text-info --geometry=600x400

learnhow2code

#11 Post by learnhow2code »

Tools like more or less make only sense in consoles.
...in the context that you think of more or less tools. i pipe things to leafpad EVERY DAY. i also use the console versions. different tools, different uses.

Every X window based editor or text viewer works like more/less by default.
a lot of them dont work well (or at all) when you try to pipe text to them. let me know which graphical editors i can pipe to. i use leafpad for that.

i tried piping ls to nano, and the cpu load jumped and nano locked me out of the term. so i opened another and killed nano.

so in terms of piping text to it, text editors do not work like more or less.

If you load long texts into any editor your will see the start of the text and will have to page down to the end, not the other way round as in a console.
less goes up and down. so does leafpad. so does nano. its not just about top vs bottom, its about scrolling in both directions.

And that's exactly why I fail to understand what this thread has to do with less
its true, in the comparison youve provided there doesnt seem to be a lot of similarity. but i find your comparison somewhat lacking.

less is a pager regardless of direction, it lets you move up AND down through text, which is what this tool does.

and unlike most editors, you can pipe stdout to its stdin.

see how its like less now?
why it is titled "script generators".
well, it *does* generate a script.

but since if you cant immediately guess the point of that you seem to insinuate that there must not be one, i will wait for you to suggest that theres no point in generating a script this way either. though i would only tell you that i had a reason for doing so.

Keep it simple: find /usr/share | yad --text-info
um, NO. i added standard options until it did what i wanted-- i wanted to be able to click on urls, so i used the option. i wanted to have it display monospace text, so i used the option.

and since it makes this TINY little window that barely shows any text and you have to resize every time, i saved myself the trouble of that by using --maxmized.

and i will continue to do it how it works for me.

what do you think the point of command line options is, anyway?

For a (speed) comparison here some examples.
i know its slow-- thats not always the first priority.

now pipe to less and select all text.

oh wait, you cant.

now pipe to less and edit the text in it

oh wait, if this is possible its VERY far from newbie friendly (at least you can search.)


i am not proposing this as a REPLACEMENT for less. nor an enhancement-- its an alternative, with slightly different features and uses. but it has more in common with less than any other command line tool.

calling it "graphical less" is exactly what i called it years ago, when someone said to me "what i should i make using pygtk?"

that tool was better than using yad for it-- so is leafpad a lot of the time. for long timeouts, yad is probably going to be better than leafpad for this.

i would understand your aversion to features if i was trying to bloat up puppy or replace less, but im not doing either-- just making a tool for my own use, and demonstrating it.

but the features are there because if i remove them, i dont like it as much. that seems like a pretty good reason to include them. and no, less will NOT do everything i use this for-- or vice versa. which is why i use both.

i can picture you reviewing less when it came out-- asking what the point of less is when more and cat already do the same thing, using less ram and half the code. thats fine. have fun.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#12 Post by MochiMoppel »

learnhow2code wrote:a lot of them dont work well (or at all) when you try to pipe text to them. let me know which graphical editors i can pipe to. i use leafpad for that.
i tried piping ls to nano, and the cpu load jumped and nano locked me out of the term. so i opened another and killed nano.
This is not a deficiency of the editor. Though many do, why should a GUI editor be able to read from stdin? Piping is extremely resource intensive compared to other methods. Why are you so obsessed with piping? You know already that it sends your cpu load through the roof, so avoid it whenever you can.
Try this and then fetch a cup of coffee:
find / | yad --text-info --geometry=600x400
Compare this with
find / >/tmp/tmpfile ; yad --text-info --geometry=600x400 --filename /tmp/tmpfile
57 sec vs. 7 sec.
its true, in the comparison youve provided there doesnt seem to be a lot of similarity. but i find your comparison somewhat lacking.
Lacking what?
less is a pager regardless of direction, it lets you move up AND down through text, which is what this tool does.
Amazing, but this is what all my examples do - and any other editor/viewer I know. What they can't do, and what even yad can't do: Load only as much (piped) text as fits the window. To achieve a functionality similar to less/more you would probably have to employ the head command or use other tricks, but this would be extremely difficult.
and unlike most editors, you can pipe stdout to its stdin.
you can do this with all my examples.
see how its like less now?
No.

learnhow2code

#13 Post by learnhow2code »

This is not a deficiency of the editor. Though many do, why should a GUI editor be able to read from stdin?
i dont know man, why should it be able to edit text?

obviously because i want it to.
Piping is extremely resource intensive compared to other methods.
thats ok, i added some ram to the pdp-8 im using.
Why are you so obsessed with piping?
why are you so obsessed with how many resources im using for tasks that run for less than 2 minutes?
You know already that it sends your cpu load through the roof, so avoid it whenever you can.
why dont i avoid it whenever i want, instead?

are you seriously saying that people should avoid pipes in /linux? because in over a decade of using gnu/linux ive NEVER heard that from anyone who wasnt extremely pedantic about streamlining cat.

pipelines are one of the best things about the operating system. no ones going to make you use them, though you dont need to wonder why people would want to.

What they can't do, and what even yad can't do: Load only as much (piped) text as fits the window. To achieve a functionality similar to less/more you would probably have to employ the head command or use other tricks, but this would be extremely difficult.
i get it now-- you think i want to do with a gui what i can do with a term window and less. no... i would just use a term window and less for that.
you can do this with all my examples.
and yet, like so many people with their own workflow, i still dont prefer to do it your way.

seriously though, this is like arguing about which calculator app to use. some have more features, some have less, some have (yuck) gnome libraries, others dont-- use the one that you find ticks all your checkboxes. tell me your favorite.

dont act like someones from another planet if theyre not in love with the one you think is the only good one.

no
life is full of mysteries. my love of unix pipes and desire to pipe text to a gui (which i explained already) will have to remain one of them, at least for you.

Post Reply