--wrap is an option for the --text-info dialog. If you don't use this option and if the text is wider than the window width, a horizontal scrollbar is added. Window size does not change.Argolance wrote:As there is a --wrap option, I thought that without this option, text would be non wrapped
YAD - Tips
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
That's a great workaround, thanks !MochiMoppel wrote:Unlike Xdialog yad does not seem to autoexpand the window but breaks lines at word boundaries. A simple way to mimic Xdialog would be to replace ordinary spaces with non-breaking spaces. Would need more sophistication if your text contains tabs.
Code:
....
I always adjust --width=... to get the text in full width (no-wrap), but it's very much depending on the font size that is configured on the system, so may not work as intended if configured font size is very large.
Fred
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Works also with gtkdialog:fredx181 wrote:That's a great workaround
Code: Select all
export MSG2
echo '<text><input>echo -e "$MSG2"</input></text>' | gtkdialog -s
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Bonjour,
Running:
Cordialement.
Strange: I also tried this trick found somewhere on the web, but it doesn't work:fredx181 wrote:I always adjust --width=... to get the text in full width (no-wrap).
Code: Select all
Impossible to analyze the command line: Impossible to analyze the entire value " " for --width
Code: Select all
# yad --version
0.33.1 (GTK+ 2.24.10)
Ah, sorry, I just meant "--width=<some-value>" for example: --width=800Argolance wrote:Bonjour,Strange: I also tried this trick found somewhere on the web, but it doesn't work:fredx181 wrote:I always adjust --width=... to get the text in full width (no-wrap).Running:Code: Select all
Impossible to analyze the command line: Impossible to analyze the entire value " " for --width
Cordialement.Code: Select all
# yad --version 0.33.1 (GTK+ 2.24.10)
(and test if e.g. 800 is enough to display the text "full width" without wrapping it, otherwise increase the value)
But Mochi's workaround does it automatically.
Fred
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Bonjour,
In the script I am tweaking, a single Xdialog function is used for different text strings:
So, there are different possible values given to the variable WIDTH I added, according to the chosen text.
Example:
... and WIDTH="" or no variable at all, if I want the text to be automatically wrapped by yad.
Cordialement.
Thank you.fredx181 wrote:Ah, sorry, I just meant "--width=<some-value>" for example: --width=800
In the script I am tweaking, a single Xdialog function is used for different text strings:
Code: Select all
msg () { yad $WIDTH --window-icon=/usr/share/icons/hicolor/48x48/apps/yapi.png --button=gtk-ok --title YaPI --text="$1" 0 0 ; }
Example:
Code: Select all
MSG1="xxxxxxx xxx xxxxxxxxxx xxxxxxxxxxx xx xxxxxxxxx xxx xxxxxxxxxx xxxxx xxx xxxxxxx xxxx xxx xxxxxxx"
MSG2="xxxxxxxxxxxxxxxxx xx xxxxxxxxxxxxxxxxxxxxxxx"
WIDTH="--width=800"
msg "$MSG1 \n\n $MSG2"
Cordialement.
- Mike Walsh
- Posts: 6351
- Joined: Sat 28 Jun 2014, 12:42
- Location: King's Lynn, UK.
Afternoon, all.
Now, then; need a wee bit of advice here, if it so please y'all.
As you all probably know by now, I'm pretty much a neophyte at Bash scripting. I've used YAD successfully in recent months for the occasional info or selector box GUI (courtesy of Grant's comprehensive guide, and the odd snippet I've found on The Linux Rain); easy enough when the required output is simply to run a single command.
What I'm not so clear about is how to capture the output of certain YAD commands.....and then to assign that output to a variable, which can then be used as part of an exec command, later in the same script.
(Remember; beginner here, so excuse me if I seem to be asking absolutely noobish-type questions. We all have to start somewhere..!)
------------------------------------
In particular, something I'm working on at the moment is making use of these two YAD commands:-
.....which brings up the directory selector dialog, and lets you select a specific directory, and this one:-
.....or a close variation on it, to allow selection of a numeric value.
In a nutshell, how do you 'capture' the output of these two commands? And, having captured that output, how can I then 'assign' it to a variable?
I'm thinking something like the following for the first example:-
.....but I've probably got the principle of the 'backticks' (`) rather muddled up. In fact probably the entire concept of variables totally wrong... A wee bit of clarification would be very much appreciated!
I have several ideas for GUIs I'd like to do for various things, but until I can get this business of capturing outputs and assigning variables straightened out in my head, I admit I'm just whistling in the wind.....
Mike.
Now, then; need a wee bit of advice here, if it so please y'all.
As you all probably know by now, I'm pretty much a neophyte at Bash scripting. I've used YAD successfully in recent months for the occasional info or selector box GUI (courtesy of Grant's comprehensive guide, and the odd snippet I've found on The Linux Rain); easy enough when the required output is simply to run a single command.
What I'm not so clear about is how to capture the output of certain YAD commands.....and then to assign that output to a variable, which can then be used as part of an exec command, later in the same script.
(Remember; beginner here, so excuse me if I seem to be asking absolutely noobish-type questions. We all have to start somewhere..!)
------------------------------------
In particular, something I'm working on at the moment is making use of these two YAD commands:-
Code: Select all
yad --form --field="MDIR:MDIR" /root
Code: Select all
yad --form --field=LABEL:NUM "10"
In a nutshell, how do you 'capture' the output of these two commands? And, having captured that output, how can I then 'assign' it to a variable?
I'm thinking something like the following for the first example:-
Code: Select all
--form --field="Choose image directory:-:MDIR" /root =`$DIR` \
I have several ideas for GUIs I'd like to do for various things, but until I can get this business of capturing outputs and assigning variables straightened out in my head, I admit I'm just whistling in the wind.....
Mike.
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Code: Select all
#!/bin/bash
read MYNUMBER MYDIR <<< $(yad --form --separator=$'\n' --field=LABEL:NUM "10" --field="MDIR:MDIR" /root)
echo "$MYNUMBER"
echo "$MYDIR"
Hi Mike,
I see while I was writing this that MochiMoppel replied already.
Anyway here's sort of how I would do it.
This should do to get DIR variable:
Say you have 2 fields, then , e.g. (note the "f 2" in cut command for OUTDIR)
Fred
I see while I was writing this that MochiMoppel replied already.
Anyway here's sort of how I would do it.
This should do to get DIR variable:
Code: Select all
SETUP=$(yad --form --field="Choose image directory:-:MDIR" /root)
# The output of yad has delimiter "|"
echo $SETUP # full output
export DIR="`echo $SETUP | cut -d "|" -f 1`"
echo $DIR
Code: Select all
SETUP=$(yad --form --field="Choose image directory:-:MDIR" /root \
--field="Choose output directory:-:MDIR" /root)
echo $SETUP # full output, next will separate them
export DIR="`echo $SETUP | cut -d "|" -f 1`"
export OUTDIR="`echo $SETUP | cut -d "|" -f 2`"
echo $DIR
echo $OUTDIR
Last edited by fredx181 on Tue 04 Sep 2018, 15:21, edited 1 time in total.
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
If your yad dialog contains only 1 field then things become simple:
In this case you could also leave the separator empty:
Code: Select all
MYDIR=$(yad --form --separator=$'\n' --field="MDIR:MDIR" /root)
Code: Select all
MYDIR=$(yad --form --separator= --field="MDIR:MDIR" /root)
Slightly more elaborate that MochiMoppel's first example but essentially using the same concept (read variable). This one is compatible with all the shells we commonly use in this forum.
Code: Select all
#!/bin/sh
# Works for bash, dash, ash. Change #!/bin/[bd]ash above accordingly.
SAMPLETXT="First line, and now
second line in TXT field"
ifs=$IFS; IFS='|' # Field separator used by 'read' and 'yad'
read -r MULTILINE TYPELESS FONT COLOUR scrap << EOF # read field values and assign to variables
$(yad --form \
--field="Multiline text:TXT" "$SAMPLETXT" \
--field="Typeless entry with\nmultiline label" "No field TYPE specified" \
--field="Font selection:FN" "Sans 12" \
--field="Colour selection:CLR" "gold" )
EOF
IFS=$ifs
[ -n "$(echo -e)" ] && echo_e= || echo_e=-e # Use echo -e except with dash
MULTILINE=$(echo $echo_e "$MULTILINE") # Convert '\n' in TXT field back into linefeeds
echo $echo_e "$MULTILINE\n$TYPELESS\n$FONT\n$COLOUR"
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]
- Mike Walsh
- Posts: 6351
- Joined: Sat 28 Jun 2014, 12:42
- Location: King's Lynn, UK.
Well, thanks for the replies, everyone. But (and it pains me to say this).....it's like so much Greek to me. Honestly.
For someone who's been using Linux for nearly 5 years (and Puppy for a little over 4 of those), my scripting skill-set is absolutely pathetic. Seriously. As stated in the first post, where scripting is concerned, I'm a raw beginner. To clarify, I can:-
1.) Create & delete files/folders.
2.) Copy & move files/folders around.
3.) Change permissions/ownerships.
4.) Create sym-links, as and where I need them.
5.) Create .desktop entries. And...
...that's about it, really. As I said, pathetic.
I've used YAD on odd occasions to create dialog selector boxes. The one I'm most proud of (:roll:) is attached at the bottom. It's my attempt to create a 'StartCenter', similar to LibreOffice, for the Softmaker FreeOffice packages I managed to accidentally throw together.
I'm under no illusions, here. The attached example could have been crafted (probably with more skill & finesse) by an absolute beginner on their second afternoon with Linux. But I do need to learn some of this other stuff, despite not really having the time (or patience!) to sit down & steadily work my way through an entire Bash scripting course. (I'd like to, but real life, unfortunately, gets in the way far too much.)
So I bumble along, picking up a little bit here, a wee bit there. To give you guys a better idea of what I'm attempting to do here, I'm also attaching the YAD script I'm working on. It's a GUI for running a slide-show with qiv.
This is as far as I've got with the script:-
The code to run the sideshow is:-
...where:-
-s starts the slide immediately
-f starts it in full-screen
-i disables the on-screen status bar
-d is the delay interval for how long you want each image to show for (in 'x' seconds)
I'd like to assign the output of the first field (the file-chooser window) to a variable, then substitute it for 'path/to/directory'.
I'd then like to assign the output of the second field (the number-chooser) to a variable, and substitute it for 'x'.
I then want to run the command itself, from the 'Run Slideshow' field button.
All this is so that a user can choose the directory of images they want to use, and select the number of seconds they want each image to show for, before moving to the next image. Having selected these two parameters, they can choose to run the slideshow.
I haven't a clue how you would accomplish these tasks.....which just proves how 'pathetic' my skill-set is.
(*shrug*)
So shoot me!!!
Mike.
For someone who's been using Linux for nearly 5 years (and Puppy for a little over 4 of those), my scripting skill-set is absolutely pathetic. Seriously. As stated in the first post, where scripting is concerned, I'm a raw beginner. To clarify, I can:-
1.) Create & delete files/folders.
2.) Copy & move files/folders around.
3.) Change permissions/ownerships.
4.) Create sym-links, as and where I need them.
5.) Create .desktop entries. And...
...that's about it, really. As I said, pathetic.
I've used YAD on odd occasions to create dialog selector boxes. The one I'm most proud of (:roll:) is attached at the bottom. It's my attempt to create a 'StartCenter', similar to LibreOffice, for the Softmaker FreeOffice packages I managed to accidentally throw together.
I'm under no illusions, here. The attached example could have been crafted (probably with more skill & finesse) by an absolute beginner on their second afternoon with Linux. But I do need to learn some of this other stuff, despite not really having the time (or patience!) to sit down & steadily work my way through an entire Bash scripting course. (I'd like to, but real life, unfortunately, gets in the way far too much.)
So I bumble along, picking up a little bit here, a wee bit there. To give you guys a better idea of what I'm attempting to do here, I'm also attaching the YAD script I'm working on. It's a GUI for running a slide-show with qiv.
This is as far as I've got with the script:-
Code: Select all
#!/bin/sh
#
# GUI for the QIV slideshow
#
yad --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --text=" Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" /root \
--field="Select timeout interval:-:NUM" \
--field="Run Q.I.V slideshow":fbtn \
Code: Select all
qiv -s -f -i -d x /path/to/directory
-s starts the slide immediately
-f starts it in full-screen
-i disables the on-screen status bar
-d is the delay interval for how long you want each image to show for (in 'x' seconds)
I'd like to assign the output of the first field (the file-chooser window) to a variable, then substitute it for 'path/to/directory'.
I'd then like to assign the output of the second field (the number-chooser) to a variable, and substitute it for 'x'.
I then want to run the command itself, from the 'Run Slideshow' field button.
All this is so that a user can choose the directory of images they want to use, and select the number of seconds they want each image to show for, before moving to the next image. Having selected these two parameters, they can choose to run the slideshow.
I haven't a clue how you would accomplish these tasks.....which just proves how 'pathetic' my skill-set is.
(*shrug*)
So shoot me!!!
Mike.
- Attachments
-
- FreeOffice.sh.gz
- FreeOffice 'StartCenter' (remove the fake .gz extension to view in Geany)
- (672 Bytes) Downloaded 63 times
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Well, then replace the echo lines of my first example withMike Walsh wrote:I'd like to assign the output of the first field (the file-chooser window) to a variable, then substitute it for 'path/to/directory'.
I'd then like to assign the output of the second field (the number-chooser) to a variable, and substitute it for 'x'.
I then want to run the command itself, from the 'Run Slideshow' field button.
Code: Select all
qiv -s -f -i -d $MYNUMBER "$MYDIR"
Hi Mike,
Thanks for picking up where I left off. I have it on my ToDo list. Fortunately, life is much easier to cope with now that I rarely remember to look at my ToDo list, especially when, as in this instance, subsumed in the simple command "ToDo" is the subsidiary command "Learn a Dialog Application" which when conscious recognition of the same is achieved results in
and Thanks to the other posters for moving this forward.
'tother Mike
p.s. Before I forget, I don't think the attachment was the one you intended.
Thanks for picking up where I left off. I have it on my ToDo list. Fortunately, life is much easier to cope with now that I rarely remember to look at my ToDo list, especially when, as in this instance, subsumed in the simple command "ToDo" is the subsidiary command "Learn a Dialog Application" which when conscious recognition of the same is achieved results in
and Thanks to the other posters for moving this forward.
'tother Mike
p.s. Before I forget, I don't think the attachment was the one you intended.
Hi!
this script works great
Problem is, the value selected doesn't get applied until the dialog is closed.
How can i grab the scale value continually, without closing the dialog?
i tried --form, but that has same issue.
Seems this should be doable without a loop
THX
this script works great
Code: Select all
#!/bin/sh
BRIGHTNESS=`yad --scale --max-value 12700000`
echo $BRIGHTNESS > /sys/class/backlight/intel_backlight/brightness
How can i grab the scale value continually, without closing the dialog?
i tried --form, but that has same issue.
Code: Select all
yad --form --field="Max size:SCL" '5!1..20!1'
THX
[b]Now[/b]: X-Tahr 2.0! StretchDog! DevuanDog!
[b]Tops[/b]: TarhNOP Vlina-R2 Racy
[b]Used[/b]: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
[i]i ♥ Puppy[/i]
[b]Tops[/b]: TarhNOP Vlina-R2 Racy
[b]Used[/b]: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
[i]i ♥ Puppy[/i]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
What issue? It's only incompletejohnywhy wrote:i tried --form, but that has same issue.Code: Select all
yad --form --field="Max size:SCL" '5!1..20!1'
Try this:
Code: Select all
yad --form --field="Max size:SCL" '5!1..20!1' --field="Set brightness:FBTN" 'sh -c "echo %1 > /tmp/brightness"'
I don't know what the '5!1..20!1' does except setting initial value to 5. Seems to be the same as a simple '5'
SCL is hardcoded to a range of 0..100. You need some multiplication in our command to translate these values to brightness values.
Thx, MochiMoppel! Good solution!
Anyway, somebody shared a better method Try this at a command-line:
https://groups.google.com/forum/#!topic ... rCcH1h7ODo
Here's my final script. Works like a dream. Now i can remove heavy 'power manager' apps!
https://groups.google.com/forum/#!topic ... rCcH1h7ODo
i think you're correct. Seems same function as --value, which sets your starting value. Can you share your source for that command? One limitation of SCL forms is they are fixed at a range of 0 to 100.MochiMoppel wrote:I don't know what the '5!1..20!1' does except setting initial value to 5. Seems to be the same as a simple '5'
Anyway, somebody shared a better method Try this at a command-line:
Code: Select all
yad --scale --print-partial
Here's my final script. Works like a dream. Now i can remove heavy 'power manager' apps!
Code: Select all
#!/bin/sh
BrPath='/sys/class/backlight/intel_backlight/'
BrCur=`cat ${BrPath}brightness`
BrMax=`cat ${BrPath}max_brightness`
BrMin=$(( (BrMax + (100 - 1)) / 100)) # 100th max-brightness, rounded up to nearest integer
yad --scale --min-value $BrMin --max-value $BrMax --value $BrCur --print-partial --title 'Set brightness' --width 300 --fixed --sticky --mouse --on-top --escape-ok --button OK --hide-value | while read BrNew
do echo "$BrNew" > ${BrPath}brightness
done
- Attachments
-
- 2018-09-05-000720_302x94_scrot.png
- (7.09 KiB) Downloaded 419 times
[b]Now[/b]: X-Tahr 2.0! StretchDog! DevuanDog!
[b]Tops[/b]: TarhNOP Vlina-R2 Racy
[b]Used[/b]: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
[i]i ♥ Puppy[/i]
[b]Tops[/b]: TarhNOP Vlina-R2 Racy
[b]Used[/b]: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
[i]i ♥ Puppy[/i]
Hi Mike, this should work:Mike Walsh wrote:This is as far as I've got with the script:-
Code:
....
yad --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --text=" Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" /root \
--field="Select timeout interval:-:NUM" \
--field="Run Q.I.V slideshow":fbtn \
The code to run the sideshow is:-
Code:
qiv -s -f -i -d x /path/to/directory
Code: Select all
yad --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --text=" Please make your selections:-" \
--field="Choose image directory:-:MDIR" '/root' \
--field="Select timeout interval:-:NUM" '1' \
--field="Run Q.I.V slideshow:FBTN" 'qiv -s -f -i -d %2 %1'
Code: Select all
SLIDESHOW=$(yad --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --width=450 --text=" Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" '/root' \
--field="Select timeout interval:-:NUM" "1" \
--buttons-layout=center --button="Run Q.I.V slideshow:0")
echo $SLIDESHOW # total output, next will split
DIR="`echo $SLIDESHOW | cut -d "|" -f 1`"
TIMEOUT="`echo $SLIDESHOW | cut -d "|" -f 2`"
qiv -s -f -i -d $TIMEOUT $DIR
Fred
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Looks a bit ugly. Mike would call it "Greek".step wrote:Code: Select all
. . [ -n "$(echo -e)" ] && echo_e= || echo_e=-e # Use echo -e except with dash MULTILINE=$(echo $echo_e "$MULTILINE") # Convert '\n' in TXT field back into linefeeds echo $echo_e "$MULTILINE\n$TYPELESS\n$FONT\n$COLOUR"
Can't we forget echo -e and just use printf? Would this be an alternative and acceptable for dash?
Code: Select all
printf %b "$MULTILINE\n$TYPELESS\n$FONT\n$COLOUR"