YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#481 Post by Mike Walsh »

Morning, Fred/Mochi:-
fredx81 wrote:Hi Mike, this should work:

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'

But the dialog stays open, don't know if you want that, this will close the dialog after clicking the button:

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

Works for me, but probably can be more compact.
I shall in all likelihood make it 'more compact', Fred, since I was intending to use the

Code: Select all

--close-on-unfocus
...feature that's been implemented in the most recent versions of YAD (v.0.38 - v.0.40).....combined with a timeout setting. I shall be supplying a recent version of YAD with the package; I've found 0.40 seems to run quite happily in all the 32-bit Pups in my kennels.....even 'oldies' like the last T2 build, Racy 5.5.

I'll give this a whirl and let ya know the outcome, mate.

-------------------------------------------

@ MochiMoppel:-
MochiMoppel wrote:
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" 
Looks a bit ugly. Mike would call it "Greek".
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"
Hah! Yup, 'Greek' is right, my son.....

See, now this is where my lack of understanding comes back to haunt me. I understand that 'echo' gives a readout in the terminal.....but what's the difference between that and 'print'?

I have to confess, I'm all for simplicity at the best of times.....one of the nice things that's always differentiated Puppy from the mainstream distros (and 'the Other' :lol:). Simple, elegant, economical code that achieves what's needed with the least resources expended.....one reason I like the '--close-on-unfocus' feature in the new versions of YAD. Saves needing to code exit stanzas!


Mike. :wink:

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

#482 Post by MochiMoppel »

Mike Walsh wrote:I have to confess, I'm all for simplicity at the best of times
That's why I tried to propose to you one of the most simple solutions, basically a 2-liner.

The printf question was for step, not for you.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#483 Post by Mike Walsh »

@ Fred:-

Hmm.

Well, as supplied, your first example merely showed the first line of text.....and nothing else.

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'
I had to add the '--form' back in front of the first '--field'. You'd also left a space after each of the 'escapes'.....it didn't like that either.

The last line, I had to change from your example to

Code: Select all

--field="Run  Q.I.V  slideshow":fbtn 'qiv -s -f -i -d %2 %1'
...because the 'field button' itself wasn't showing. But it still doesn't do anything, neither as original, as per your mods, or as per my mods. I can't help thinking there's other stuff needs adding in, y'know.

Previously, whenever I've started an app from a field button, it's always needed double-quotation marks around the command ("), rather than singles (plus a space, then an 'escape' to finish the line off). Also (and I could be wrong on this), I can't help thinking another step is needed to actually 'enter' the 'timeout value'. With the file-chooser dialog, you get an 'OK' at the end when you close it.....which 'enters' the value. With the timeout as it is, there's nothing like that; if you run that line from the terminal, it brings the wee box up where you select your number.....then 'closing' the box with the 'OK' button 'enters' it.....and the value is printed in the terminal.

(In my version, all you're doing is choosing the numeric value.....but you don't actually 'enter' it.)

Are my 'musings' making any sense here? (i mean, if the GUI needs re-designing, then so be it! I don't care about the 'look' of it - this is simply an initial 'rough-out', after all - so long as it works; it's gotta be functional, obviously. Hell, I wish I had a 'head' for this kinda thing.....) :roll:


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#484 Post by fredx181 »

Hi Mike, it may have to do with copy/paste from the forum
Here is exactly the same as one-liner, hopefully that doesn't give same or similar problem.
(EDIT: well.. I pasted here, copied from a oneliner in Geany, when I copy and paste from here back in Geany it appears again as one-liner)

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'
I tested and slideshow works fine for me.

Fred

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#485 Post by Mike Walsh »

@ Fred:-

D'oh..! Ooh, I am so embarrassed... :oops:

I owe you an apology, mate;I am just having 'one of those days'. :roll:

I'm in Xenialpup64 today - first time for a few days, in fact. The reason for it not working? Ve-e-ery simple. Qiv wasn't, in fact, installed.... (*cringe*)

Your script works nicely; just what the doctor ordered, in fact. I've been running the test scripts from one of my 'common' data partitions.....'cos scripts are not 'architecture-specific', like apps are. Even so, it does help to actually install the binaries that you want the scripts to call...

Aarrgh!!

-----------------------------

One quick question, if I may? The two variables you've used ('%1', '%2').....do I take it that refers to 'Field1' and 'Field2'? Or is it just 'Line1' & 'Line2' (or 'item1'/'item2'), etc? I still want to get some of this stuff straight in this bag of mush I jokingly refer to as my head..! :lol:

Cheers anyway, Fred; nice one. Thanks again.


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#486 Post by fredx181 »

Mike Walsh wrote:@ Fred:-

D'oh..! Ooh, I am so embarrassed... :oops:

I owe you an apology, mate;I am just having 'one of those days'. :roll:
No problem at all, Mike ! :)
The two variables you've used ('%1', '%2').....do I take it that refers to 'Field1' and 'Field2'?
Yes, what's set from the --field variables.

Fred

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#487 Post by misko_2083 »

lika wrote:
misko_2083 wrote:Added pv command to display the progress. One more dependancy to install but I see no other way for now.
Hello, misko_2083.

What about coproc, tail or stdbuf instead pv?

And:
- there are 2 times expanded "Sure_Command" in the script, maybe use "export?"
- attach the final dialog (window about successful installation) to main window? Is it possible?
- is there way to fix top border (thin line) of the progress plug? But "--fixed" option don't applied for a plug.
- and maybe make the button "Abort" inactive at the beginning and at the end of the installation?

Replace the line:

Code: Select all

pv -n 2>$percentage_pipe | tar xJfv archive.tar.xz -C "$1" 2>&1 >> $percentage_pipe & echo $! > "$main_proc_id"
and now no visual progressbar... :?
.
You forgot xzcat. Yad has some limitations. Maybe python would be a better option.
fredx181 wrote:

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'
I tested and slideshow works fine for me.
That just gave me an idea. Slideshow inside the yad paned tab. :)
It's possible to draw over the yad window. X will allow applications to do just anything.
But the script would require "xloadimage" and xdotool. It's in debian repos at least.

Code: Select all

#!/bin/bash

id="$((${RANDOM}+$RANDOM))"

yad --class tab-slideshow --plug=$id --tabnum=1 --text="\n\n\n\t\t\tLoading" & TAB_PID=$!

yad --plug=$id --tabnum=2 --form &

yad --paned --class "yad-slideshow" --key=$id --tab="tab1" --tab="tab2"  --active-tab='2' --width=900 --height=600 --splitter=300 --fixed & YPID=$!

# Wait untill the tab is created, that is until window name appears
until xdotool getwindowname "$(xdotool search --any --pid $TAB_PID --class "tab-slideshow" 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do
        # sleep until the window opens
        sleep .1
done

# Decimal window id
WindowID="$(xdotool search --class "tab-slideshow" 2>/dev/null | tail -1)"

# Hexadecimal, that's what xloadimage accepts
WindowIDHex=$(printf "0x%08x" ${WindowID})

sleep .5

while true; do
        #Set the folder here
        for NAME in $HOME/Pictures/*.png; do
              xloadimage -windowid $WindowIDHex "$NAME" -quiet 2>/dev/null
             #Set duration here
             sleep 1
       done
done & XLOAD_IMAGE=$!

wait $YPID

kill -SIGKILL $XLOAD_IMAGE

exit 0
Remember to change the folder in the script.

This reminds me of ubuntu installer.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#488 Post by step »

MochiMoppel wrote:
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"
Looks a bit ugly. Mike would call it "Greek".
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"
Yes, that's nice. I wasn't aware of the %b format for printf. dash seems to support it. Thanks.
[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]

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#489 Post by Mike Walsh »

Fred:-

I do apologise for this. Got another question for you, I'm afraid....

In the qiv 'exec stanza', the '-f' parameter determines full-screen status, yes? I want to add a check-box, to allow the user to select full-screen (or not; their choice). Like this:-


Image


Checked gives the value 'TRUE |'.
Unchecked returns (not surprisingly) 'FALSE |'.

So far, I've added this extra bit:-

Code: Select all

 yad  --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --back=yellow --text="     Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" '/root' \
--field="Select timeout interval:-:NUM" '1' \
--field="Fullscreen:CHK" \
--field="Run  Q.I.V  slideshow":fbtn 'qiv -s -f -i -d %2 %1'
I guess this 3rd field could be '%3'?

Now; here's the question, 'cos I can't figure this bit out at all. How do checkbox values work in scripting? How can I arrange it so that 'TRUE' inserts the '-f':-

Code: Select all

'qiv -s -f -i -d %2 %1'
.....and 'FALSE' leaves it out?

Code: Select all

'qiv -s -i -d %2 %1'
I do remember that in old-style BASIC, many, many moons ago in my youth, you'd simply do this with an 'EITHER'.....'OR' conditional statement. But how's this achieved in Bash? Again.....sorry for the 'noob-type' questions. :oops: But if you never ask, you never learn.....and I do want to learn some scripting 'basics'..!


Mike. :wink:

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

#490 Post by MochiMoppel »

step wrote:Yes, that's nice. I wasn't aware of the %b format for printf. dash seems to support it. Thanks.
You're welcome, but let's forget %b format too. Doesn't make a difference here. printf decodes escape sequences by default and a plain printf should be all that is needed here - unless dash complains :lol:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#491 Post by fredx181 »

Hi Mike,
I guess this 3rd field could be '%3'?

Now; here's the question, 'cos I can't figure this bit out at all. How do checkbox values work in scripting? How can I arrange it so that 'TRUE' inserts the '-f':-

Code:
'qiv -s -f -i -d %2 %1'
Try this:

Code: Select all

yad --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --back=yellow --text="     Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" '/root' \
--field="Select timeout interval:-:NUM" '1' \
--field="Fullscreen:CHK" "" \
--field="Run  Q.I.V  slideshow":fbtn 'bash -c "[ %3 = TRUE ] && qiv -s -f -i -d %2 %1 || qiv -s -i -d %2 %1"'
It's a little more code as you see, checking first if %3 = TRUE, <qiv command fullscreen> else <qiv command not-fullscreen>

Hey... no need to apologize, I learn from this also :D

EDIT: if you want Fullscreen checked by default, make the field:

Code: Select all

--field="Fullscreen:CHK" "TRUE"
EDIT2: I experimented some more (wanted the button command in a function)

Code: Select all

#!/bin/bash
export load_cmd='@bash -c "button_cmd %1 %2 %3 %4 %5 %6"'

function button_cmd () {
[ $3 = TRUE ] && FS="-f" || FS=""
qiv -s $FS -i -d $2 $1
}
export -f button_cmd

yad --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --back=yellow --text="     Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" '/root' \
--field="Select timeout interval:-:NUM" '1' \
--field="Fullscreen:CHK" "TRUE" \
--field="Run  Q.I.V  slideshow":fbtn "$load_cmd"
Advantage is that you can easily add more checkboxes and edit function button_cmd, like:

Code: Select all

function button_cmd () {
[ $3 = TRUE ] && FS="-f" || FS=""
[ $4 = TRUE ] && ...... || .....
........
}
EDIT3: Me again :) added checkbox "Shrink image(s) larger than the screen to fit" (EDIT, on second thought, it may better be the default)

Code: Select all

export load_cmd='@bash -c "button_cmd %1 %2 %3 %4 %5 %6"'

function button_cmd () {
[ $3 = TRUE ] && FS="-f" || FS=""
[ $4 = TRUE ] && SD="-t" || SD=""
qiv -s $FS $SD -i -d $2 $1
}
export -f button_cmd

yad --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --back=yellow --text="     Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" '/root' \
--field="Select timeout interval:-:NUM" '1' \
--field="Fullscreen:CHK" "TRUE" \
--field="Shrink image(s) larger than the screen to fit:CHK" "TRUE" \
--field="Run  Q.I.V  slideshow":fbtn "$load_cmd"
Btw, there's also the "-m" option, scaling to full size of screen.

EDIT4: OK, last :lol: "Shrink image(s) larger than the screen to fit" is default and added checkbox "Zoom to screen size and preserve aspect ratio"

Code: Select all

export load_cmd='@bash -c "button_cmd %1 %2 %3 %4 %5 %6"'

function button_cmd () {
[ $3 = TRUE ] && FS="-f" || FS=""
[ $4 = TRUE ] && ZM="-m" || ZM=""
qiv -t -s $FS $ZM -i -d $2 $1
}
export -f button_cmd

yad --no-buttons --center --window-icon=/usr/local/lib/X11/pixmaps/qiv.png --title="Q.I.V Slideshow" --form --width=450 --back=yellow --text="     Please make your selections:-" \
--form --field="Choose image directory:-:MDIR" '/root' \
--field="Select timeout interval:-:NUM" '1' \
--field="Fullscreen:CHK" "TRUE" \
--field="Zoom to screen size and preserve aspect ratio:CHK" "" \
--field="Run  Q.I.V  slideshow":fbtn "$load_cmd"
Fred

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#492 Post by Mike Walsh »

Morning, Fred.

O-kaaay. Right. (That little lot'll give me summat to think about for a while! :lol:)

See, I started out with this kind of thing way back in the late 70's/early 80's, and - courtesy of a Commodore 64 the old man treated me & my younger brother to for Xmas '81 or '82 - started playing around and experimenting with Commodore BASIC.

John was at the age when he was just discovering girls for the first time, and had no time for it. I'd passed through that phase a few years before ( :D ), so I pretty much had it to myself. Wrote myself a 'Hangman' game for it, with which I was pretty 'chuffed'!

--------------------------------------

Trouble is, I'm still thinking in terms of BASIC (what I can remember of it!), so I find Bash a bit confusing, y'see.

The pair of double-quotes after '...:CHK' ("").....what are those actually doing? I know what the && is for, but what does the 'double-pipe' ('||') in the (now) 2-way exec stanza do? Does that allow it to work in both directions, dependent on condition? (I know what a 'single-pipe' does.) I'm slowly getting my head around some of this stuff, but I'm a wee way from being able to string it all together yet...!

You're kind of acting a bit like my night-school computer class tutor had to.....except this is now a totally different language.....


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#493 Post by fredx181 »

Mike wrote:The pair of double-quotes after '...:CHK' ("").....what are those actually doing? I know what the && is for, but what does the 'double-pipe' ('||') in the (now) 2-way exec stanza do? Does that allow it to work in both directions, dependent on condition? (I know what a 'single-pipe' does.) I'm slowly getting my head around some of this stuff, but I'm a wee way from being able to string it all together yet...!

Without the double-quotes after '...:CHK' it didn't work for me, apparently it needs to be there to at least give empty value, not sure why.

About '&&' and '||' , it's short equivalent of if... else... condition, for example this:

Code: Select all

[ %3 = TRUE ] && qiv -s -f -i -d %2 %1 || qiv -s -i -d %2 %1
Works the same as this:

Code: Select all

if [ %3 = TRUE ]
then        # (as && , if condition matched)
qiv -s -f -i -d %2 %1
else        # (as || , if condition not matched, do something else)
qiv -s -i -d %2 %1
fi
Have fun!

Fred

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#494 Post by step »

MochiMoppel wrote:
step wrote:Yes, that's nice. I wasn't aware of the %b format for printf. dash seems to support it. Thanks.
You're welcome, but let's forget %b format too. Doesn't make a difference here. printf decodes escape sequences by default and a plain printf should be all that is needed here - unless dash complains :lol:
I think my original intent was to output all "\n"s as newlines, including the "\n"s that are stored in $MULTILINE, so %b is correct (you were).
%s instead would only expand the "\n"s that separate the variables in printf %s "$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]

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

#495 Post by MochiMoppel »

step wrote:I think my original intent was to output all "\n"s as newlines, including the "\n"s that are stored in $MULTILINE, so %b is correct (you were).
%s instead would only expand the "\n"s that separate the variables in printf %s "$MULTILINE\n$TYPELESS\n$FONT\n$COLOUR".
Well, yes, %b is correct but redundant, %s would be wrong, it would not even expand the "\n"s that separate the variables since the whole argument is one big string and it doesn't matter if the "\n"s are in the variables or between them. Just try it. The only difference to echo -e is that there is no final linefeed, making find "some_string" the same as echo -en "some_string". Only if you want to emulate echo -e you would need %b. The whole thing then would have to look like this: printf "%b\n" "some_string_with_escape_codes_in_it" . Confused? I hope not.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#496 Post by Mike Walsh »

Hi again, Fred.

Okay; here's 'Mk 2'.


Image



I've used the extra code you supplied to add the 'Full-screen' selector. Have added another 'cmd_function' to permit enabling/disabling of the status-bar in full-screen mode (it appears to be hard-coded in normal viewing mode, and isn't switchable.)

Also added an 'info' button, which brings up a second YAD 'text' window, explaining some of the functions.....and a 'Quit' button, to exit.

Code: Select all

#!/bin/sh
#
# Launcher for the 'Q.I.V Slideshow' © Mike Walsh, Sep 2018 - with thanks to the 'Puppy' crew (and Fredx181 in particular) for assistance
#
export load_cmd='@bash -c "button_cmd %1 %2 %3 %4 %5 %6"'

function button_cmd () {
[ $3 = TRUE ] && FS="-f" || FS=""
[ $4 = FALSE ] && SB="-i" || SB=""
qiv -s $FS $SB -m -t -d $2 $1
}
export -f button_cmd 

yad  --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" '1' \
--field="Fullscreen:CHK" "TRUE" \
--field="Enable/disable status bar (full-screen only):CHK" "FALSE" \
--field="Run  Q.I.V  slideshow":fbtn "$load_cmd" \
--button="Information":qiv-gui-info.sh --button="Quit":1
I've left the '-m -t' flags in the exec stanza as they are. That way, resizing of images is entirely automatic; IMHO, that's better left as default behaviour.

I think it's fair to say I'm slowly getting the hang of this 'variables' stuff. I'll get there eventually!


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#497 Post by fredx181 »

Hi Mike, congrats ! it's working well.
Just one thing (but I don't intend to put you on more stress than you possibly are already :) )
I didn't really notice earlier, but I see you are using the "MDIR" option (multiple directories) for the directory select field.
(EDIT: So I assumed that your intention is to make it work with multiple directories)
However multiple directories is supported by qiv, it doesn't work when trying to select more than one directory.
The following should work with "MDIR" (added DIRS variable), but the directory names cannot contain spaces.
(supporting that should probably be possible also, but needs more complex code)

Code: Select all

#!/bin/sh
#
# Launcher for the 'Q.I.V Slideshow' © Mike Walsh, Sep 2018 - with thanks to the 'Puppy' crew (and Fredx181 in particular) for assistance
#
export load_cmd='@bash -c "button_cmd %1 %2 %3 %4 %5 %6"'

function button_cmd () {
DIRS=$(echo $1 | sed 's|!| |g')
[ $3 = TRUE ] && FS="-f" || FS=""
[ $4 = FALSE ] && SB="-i" || SB=""
qiv -s $FS $SB -m -t -d $2 $DIRS
}
export -f button_cmd

yad --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="Fullscreen:CHK" "TRUE" \
--field="Enable/disable status bar (full-screen only):CHK" "FALSE" \
--field="Run  Q.I.V  slideshow":fbtn "$load_cmd" \
--button="Information":qiv-gui-info.sh --button="Quit":1
Fred

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#498 Post by Mike Walsh »

Hi, Fred.

Mm! I've just discovered that about 'no spaces allowed in the directory name'.....literally this last few minutes.

Back in Xenial64 ATM. Couldn't work out why it was giving a problem with the 64-bit version, because this same directory viewed fine in the 32-bit version before I changed the space for an under-slash.....

Heigh-ho; never mind. It's behaving itself now.

(*shrug*)


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#499 Post by fredx181 »

Hi Mike, I couldn't resist trying to improve :)
Selecting multiple directories works and directory names may contain spaces now.(oh, and added checkbox: "Recursively include all files")

Code: Select all

#!/bin/bash
#
# Launcher for the 'Q.I.V Slideshow' © Mike Walsh, Sep 2018 - with thanks to the 'Puppy' crew (and Fredx181 in particular) for assistance
# fredx181 20180907, supports now selecting multiple directories and directory names containing spaces
# and added checkbox "Recursively include all files"
# 
export load_cmd='@bash -c "button_cmd %1 %2 %3 %4 %5 %6"'

function button_cmd () {
[ $3 = TRUE ] && FS="-f" || FS=""
[ $4 = FALSE ] && SB="-i" || SB=""
[ $5 = TRUE ] && RC="-u" || RC=""
OLDIFS="$IFS"
IFS=$'\n'
qiv -s $FS $SB $RC -m -t -d $2 $(echo -e "$1" | tr '!' '\n')
IFS=$OLDIFS
}
export -f button_cmd

yad --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="Fullscreen:CHK" "TRUE" \
--field="Enable/disable status bar (full-screen only):CHK" "FALSE" \
--field="Recursively include all files:CHK" "FALSE" \
--field="Run  Q.I.V  slideshow":fbtn "$load_cmd" \
--button="Information":qiv-gui-info.sh --button="Quit":1
Fred

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#500 Post by Mike Walsh »

Hi, Fred.

Hah! Y'know, this is in danger of turning into 'Fred's Q.I.V slideshow GUI...'... :lol: :lol:

Nah, you do what you like with it, mate. I know you like playing around with code; if, in the long run, this benefits the whole community by trying out new things (which can then be incorporated into other apps, etc.)......I'm all for that.

This was only a one-off 'experiment' on my part, trying things out for myself. You have fun with it.


Mike. :wink:

Post Reply