v1cont / yad

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

Colon use in ID field of --button can cause problems, such as when a URL is entered #149

Open hart0 opened 2 years ago

hart0 commented 2 years ago

Working as expected: Button says "Test", clicking it opens a new Firefox window to google.com

yad --button="test:firefox google.com"

When there is 2nd colon included, such as in this example when https:// is specified, the button instead says "test:firefox https" and clicking it attempts to execute the command "//google.com"

yad --button="test:firefox https://google.com"

I couldn't figure out any way to escape the 2nd colon to get this to work

phenixia2003 commented 2 years ago

Hello,

With bash you can circumvent this issue as below :

function open_https_url() { local URL=$1 firefox "https://${URL}" }

export -f open_https_url yad --use-interp --button="Test:open_https_url google.com"

AFAIK, --use-interp was introduced in yad 3.0. So, if you use an earlier version of yad, you'll need to run yad as below instead:

yad --button="Test:bash -c \"open_https_url google.com\""

Hope this helps.

-- SeB

hart0 commented 2 years ago

Hello,

With bash you can circumvent this issue as below :

function open_https_url() { local URL=$1 firefox "https://${URL}" } export -f open_https_url yad --use-interp --button="Test:open_https_url google.com"

AFAIK, --use-interp was introduced in yad 3.0. So, if you use an earlier version of yad, you'll need to run yad as below instead:

yad --button="Test:bash -c \"open_https_url google.com\""

Hope this helps.

-- SeB

Thanks, I ended up going with something very similar albeit more complex than I was intending in order to pass some variables and also the GUI's PID (in an exported function) in order to also be able to close the GUI from any of the form button presses as well