pass arguement to --text-info ?

1,778 views
Skip to first unread message

dave

unread,
Feb 19, 2012, 3:27:40 PM2/19/12
to yad-common
Hi, I have this yad stmt:

yad --text-info --show-uri --width=600 --height=500 --center --wrap --
name="new note" --window-icon="text-editor" \
--title=$"NewNote" --button="gtk-save:0" --button="open file:
2" --button="gtk-close:1" \
--editable --filename=testnotes.txt > testnotes.txt

It successfully puts up a multi-line text box that you can enter into
and pass the contents to a file.

I'd like to put the string "$@" from a previous script as a suggested
text in the text info box that comes up but i can't figure it out.

What I'm after is similar to this which does work:
term=$(yad --title="what is your quest?" --width=300 --entry --entry-
text="$SUGGEST")

the problem is that that is a single line text entry and I need a
multi line entry box.

Thanks,
Dave
Message has been deleted

slo.sleuth

unread,
Feb 19, 2012, 5:51:34 PM2/19/12
to yad-c...@googlegroups.com
try something like:
 
echo "$@" | \
yad --text-info \
    --show-uri \
    --width=600 \
    --height=500 \
    --center \
    --wrap \
    --
name="new note" \
    --window-icon="text-editor" \

cdaaawg

unread,
Apr 2, 2012, 7:51:49 PM4/2/12
to yad-c...@googlegroups.com
Your code does not work on my system running yad version 0.17.1.1 There is no --name dialog as per the yad man page. The $@ shell variable is not displayed in the --text-info dialog. If I remove --name, leaving a blank line in its place, $@ is expanded, but bash throws an error stating
--window-icon=text-editor: command not found
If I remove the blank line, I get no error but the variable does not display in the --text-info dialog even though it is being passed to the script, as `echo $@` displays it on the command line. Can anyone tell me what is happening here? Thanks for any enlightenment

Victor Ananjevsky

unread,
Apr 3, 2012, 12:17:41 AM4/3/12
to yad-c...@googlegroups.com
On Mon, 2 Apr 2012 16:51:49 -0700 (PDT)
cdaaawg <cda...@gmail.com> wrote:

> Your code does not work on my system running yad version 0.17.1.1 There is
> no --name dialog as per the yad man page. The $@ shell variable is not
> displayed in the --text-info dialog. If I remove --name, leaving a blank
> line in its place, $@ is expanded, but bash throws an error stating
> --window-icon=text-editor: command not found
> If I remove the blank line, I get no error but the variable does not
> display in the --text-info dialog even though it is being passed to the
> script, as `echo $@` displays it on the command line. Can anyone tell me
> what is happening here? Thanks for any enlightenment
>

--name is a standard gtk option. you can see info about it in output of yad --help-gtk.

when you remove "--name ... " you forgot to add a backslash to the end of line, that's why
bash interprets --window-icon=text-editor as a new command


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

daaawg

unread,
Apr 3, 2012, 9:02:06 AM4/3/12
to yad-c...@googlegroups.com
OK, but where does the value for the --name option show up? When I `wmctrl -l` or `xwininfo`, the value for name is not there, only the value for --title. Also, the command line parameters are displayed ONLY when there is an error, such as if the blank line is left without a continuation character, but then the lines following that blank line are of course not recognized by yad. This is very confusing! Is the order of options important? I ask this because I have rearranged them from the original so they are logically grouped. Here is the code:

#!/bin/bash

echo "$@" | \
yad \
    --width=600 \
    --height=500 \
    --title="NewNote" \
    --window-icon="text-editor" \
    --name="YAD_text-info" \
    --text-info \
    --editable \
    --wrap \
    --always-print-result\

    --button="gtk-save:0" \
    --button="open file:2" \
    --button="gtk-close:1" \
    --filename=testnotes.txt > testnotes.txt

btn=$?

echo $@
echo "Button: $btn"

exit

FFRR

unread,
Apr 3, 2012, 9:28:13 AM4/3/12
to yad-c...@googlegroups.com, cda...@gmail.com
Instead of a blank line, try adding a \ if you need to have the space

You didn't have a space between   --always-print-result & \  ->   --always-print-result\  so this may have caused problems

--name shows up as WM_CLASS if you use xprop

What is the syntax for running your script ? Simply ./script.sh or is there more to it.

FFRR

Victor Ananjevsky

unread,
Apr 3, 2012, 9:31:16 AM4/3/12
to yad-c...@googlegroups.com
В Tue, 3 Apr 2012 06:02:06 -0700
daaawg <cda...@gmail.com> писал:

> OK, but where does the value for the --name option show up? When I `wmctrl
> -l` or `xwininfo`, the value for name is not there, only the value for
> --title.

use wmctrl -l -x

> Also, the command line parameters are displayed ONLY when there is
> an error, such as if the blank line is left without a continuation
> character, but then the lines following that blank line are of course not
> recognized by yad. This is very confusing! Is the order of options
> important? I ask this because I have rearranged them from the original so
> they are logically grouped. Here is the code:


you can't use --filename option and stdin simultaneously. if you need this, try something like

echo -e "$@\n$(< testnotes.txt)" | yad --text-info > testnotes.txt


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

daaawg

unread,
Apr 3, 2012, 3:46:55 PM4/3/12
to FFRR, yad-c...@googlegroups.com
@FFRR
I left the blank line in the code simply to illustrate what its effects were on the script.

No whitespace between the yad option and the continuation character (in this case "\") is not a problem. Try it! ;)

Any character AFTER the continuation character and BEFORE a newline is a problem. Spaces unaccompanied by printable characters are especially troublesome since they are invisible unless your editor is set to display them by highlighting. Try it! ;)

The whole idea behind this snippet of code is to test the passing of parameters into the yad "--text-info" dialog, so of course we must test the case where parameters are passed from the command line. Thus the first test case is as follows:
$ script-name.sh param1 param2 ... paramN
Of course, to be thorough, we must also test the case with no parameters on the command line:
$ script-name.sh

Hope this clears things up.

Carl
Reply all
Reply to author
Forward
0 new messages