Following on from this question, and changing the question, another way to write the Yad notebook script is as follows. This removes the &
from res1 &
and asynchronous operation.
As mentioned @Barmar, "scripts operate sequentially, whereas there is no way to have multiple variable assignments start concurrently and wait for a different pane to get a response." Which is probably the answer to this question.
This is one solution but it creates a file for the output of both Yad panes. Could be one file with tee -a
on the second pane and trimming characters with sed? Not the most elegant solution. And it fails on the number of characters.
#!/bin/bash
#ifs.sh
# no AT bridge
export NO_AT_BRIDGE=1
# yad notebook key
key=$RANDOM
# system management tab
sysvar=$(yad --plug=$key --tabnum=2 --form --columns=1 --editable --separator='' \
--text="<b>Text</b>" \
--field="Threads":NUM \
'3!1..4!1!0' \
--field="Memory":SCL \
'50!10..100!1!0' | tee 0 ) &> res2 &
provar=$(yad --plug=$key --tabnum=1 --form --columns=1 --editable --separator='' \
--text="<b>Text</b>" \
--field="Format":CB \
'RAW!OTHER' \
--field="Calibrate":CHK \
'TRUE!FALSE' | tee 1 ) &> res1 &
yad --notebook --key=$key --center --tab="<b>Process and options</b>" --tab="<b>System settings</b>" \
--text="Text" \
--title="Asterism" \
--buttons-layout=spread \
--button=Quit:1 \
--button=Process:0 2>/dev/null
ret=$?
if [ $ret -eq 0 ]; then
value=`cat 0`
values=`cat 1`
processors=$(echo "$value" | sed s'/.........$//')
memlimit=$(echo "$value" | sed 's/^........//')
echo $processors $memlimit
raw=$(echo "$values" | sed s'/.....$//')
cal=$(echo "$values" | sed 's/^...//')
echo $raw $cal
fi
exit
and, this is the output...
+ sysvar=3.00000050
+ provar=RAWFALSE
+ ret=0
+ '[' 0 -eq 0 ']'
++ cat 0
+ value=3.00000050
++ cat 1
+ values=RAWFALSE
++ echo 3.00000050
++ sed 's/.........$//'
+ processors=3
++ echo 3.00000050
++ sed 's/^........//'
+ memlimit=50
+ echo 3 50
3 50
++ echo RAWFALSE
++ sed 's/.....$//'
+ raw=RAW
++ echo RAWFALSE
++ sed 's/^...//'
+ cal=FALSE
+ echo RAW FALSE
RAW FALSE
+ exit
EDIT: This is a bash solution using sed. Write the yad output to file and edit with sed, rather than attempting to create variables from the yad string - no point.
EDIT: using cut https://stackoverflow.com/a/52055600/5057161
#!/bin/bash
#ifs.sh
# no AT bridge
export NO_AT_BRIDGE=1
# yad notebook key
key=$RANDOM
# system management tab
yad --plug=$key --tabnum=2 --form --columns=1 --editable --separator=':' \
--text="<b>Text</b>" \
--field="Threads":NUM \
'3!1..4!1!0' \
--field="Memory":SCL \
'50!10..100!1!0' > sys | > res2 |
yad --plug=$key --tabnum=1 --form --columns=1 --editable --separator=':' \
--text="<b>Text</b>" \
--field="Format":CB \
'RAW!OTHER' \
--field="Calibrate":CHK \
'TRUE!FALSE' > pro | > res1 |
yad --notebook --key=$key --center --tab="<b>Process and options</b>" --tab="<b>System settings</b>" \
--text="Text" \
--title="Asterism" \
--buttons-layout=spread \
--button=Quit:1 \
--button=Process:0 2>/dev/null
ret=$?
if [ $ret -eq 0 ]; then
thd=$(echo | sed 's/.......:.*//' < sys)
mem=$(echo | sed 's|........:||;s/:$//' < sys)
img=$(echo | sed 's/:.*//' < pro)
cal=$(echo | sed 's/:$//;s|.*:||' < pro)
fi
rm sys pro
exit