v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
657 stars 58 forks source link

File protocol or console logs - but not both #150

Open the0neWhoKnocks opened 2 years ago

the0neWhoKnocks commented 2 years ago

Currently I have

echo "$GUI" | yad \
  --window-icon="system-software-install" \
  --title="Post Install" \
  --width=900 \
  --height=500 \
  --center \
  --html \
    --print-uri \
  --no-buttons \
2>&1 | while read -r line; do
  # console parsing code
done

With the above I'm able to send my output via console.log.

I wanted to separate some logic so I added the below in my GUI html file.

<script type="application/javascript" src="file:///home/USER/test.js"></script>

but the file doesn't load.

So I then added

echo "$GUI" | yad \
  --window-icon="system-software-install" \
  --title="Post Install" \
  --width=900 \
  --height=500 \
  --center \
+  --browser \
+  --uri="file://${PWD}/gui.html" \
  --html \
    --print-uri \
  --no-buttons \
2>&1 | while read -r line; do
  # console parsing code
done

and the code in the external test.js now executes, but now my console.logs no longer fire.

Is this expected behavior? If so, is there a way to utilize the file:// protocol and have console.log output to stdout?

v1cont commented 2 years ago

yes, this is the expected behavior. in browser mode you are follow the links you clicked instead of printing them. to change this you must specify --uri-handler command. for example "--uri-handler=echo", or your own command if you need to transform urls before using them

the0neWhoKnocks commented 2 years ago

I'm not using the url mechanism because it was too limited, I'm using console.log instead.

To reiterate

is there a way to utilize the file:// protocol and have console.log output to stdout?

Perhaps via a webkit flag? I'm not sure how the log redirection was implemented, but it'd be nice to have that feature parity.