Use bash function inside yad form.

422 views
Skip to first unread message

lid gnulinux

unread,
Oct 17, 2022, 7:00:54 PM10/17/22
to yad-common
I have this bash function and it's combined at yad's script.

#!/bin/bash

wstock () {
        wofi -Q $1 -l 1 -W 15% --line 8 -p "YWAL" --normal-window
}

yad --form --width=120 \
        --title="YWAL" \
        --align=left \
        --field=" All Apps  ":fbtn "kill-launch.sh wofi wofi 'wstock app''" \
        --no-buttons

(but) 'wstock app' is not recognized, How to call the bash function properly ? The only work way is make separated script.

Victor Ananjevsky

unread,
Oct 18, 2022, 2:14:04 AM10/18/22
to yad-c...@googlegroups.com

hi

export a function to make it visible for subshells.
to do this just add "export -f wstock" after function definition

and pay attention that this is a bash specific feature

Mon, 17 Oct 2022 16:00:54 -0700 (PDT)
lid gnulinux <lidgn...@gmail.com> написав:
--
wbr
Victor Ananjevsky <vic...@sanana.kiev.ua>

lid gnulinux

unread,
Oct 18, 2022, 2:24:01 AM10/18/22
to yad-common
Hello, victor, it works, thanks. Have a great day... I'll close it now.

lid gnulinux

unread,
Oct 18, 2022, 10:16:01 PM10/18/22
to yad-common
Hello, I change my script into this and then it doesn't work when I press button wofi won't launch.

The script :

#!/bin/bash

kila () {
        if pgrep -x "$1" > /dev/null; then
                killall $2
        else    
                wofi -Q $3 -l 1 -W 15% --line 8 -p "YWAL" --normal-window
        fi
}

export -f kila

#killlaunch wofi wofi app
yad --form --width=120 \
        --field=" All Apps  ":fbtn "kila wofi wofi 'app'" \
        --field=" Accesories":fbtn "kila wofi wofi tool" \
        --field=" Multimedia":fbtn "kila wofi wofi Audio" \
        --field=" Graphics  ":fbtn "kila wofi wofi Graphic" \
        --field=" Systems   ":fbtn "kila wofi wofi System" \
        --field=" Settings  ":fbtn "kila wofi wofi Setting" \
        --field=" Editor    ":fbtn "kila wofi wofi Text" \
        --field=" Internet  ":fbtn "kila wofi wofi Network" \
        --no-buttons

Thanks,

Victor Ananjevsky

unread,
Oct 19, 2022, 2:43:01 AM10/19/22
to yad-c...@googlegroups.com
hi

add --use-interp parameter

Tue, 18 Oct 2022 19:16:01 -0700 (PDT)

lid gnulinux

unread,
Oct 19, 2022, 8:02:17 AM10/19/22
to yad-common
Thanks, Victor, I still don't get / catch what the " --use-interp" will do on my script, I'll dig it deeper.

lid gnulinux

unread,
Oct 19, 2022, 8:13:27 AM10/19/22
to yad-common

Ananas

unread,
Oct 19, 2022, 12:19:11 PM10/19/22
to yad-c...@googlegroups.com
--use-interp says yad to launch all commands through "bash -c".
so using this parameter is more accurate than adding bash -c to all of
your callbacks.
especially if you use functions from your script as a handlers

ср, 19 жовт. 2022 р. о 15:13 lid gnulinux <lidgn...@gmail.com> пише:
> --
> You received this message because you are subscribed to the Google Groups "yad-common" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/yad-common/f4819021-cb31-4122-b8ae-199691192da9n%40googlegroups.com.



--
wbr,

Victor "Ananas" Ananjevsky

lid gnulinux

unread,
Oct 19, 2022, 9:24:39 PM10/19/22
to yad-common
Okay, noted, I'll try it later and find out. Thanks.
Reply all
Reply to author
Forward
0 new messages