4

I have the following twenty-six files in a folder:

$ ls
a.txt  c.txt  e.txt  g.txt  i.txt  k.txt  m.txt  o.txt  q.txt  s.txt  u.txt  w.txt  y.txt
b.txt  d.txt  f.txt  h.txt  j.txt  l.txt  n.txt  p.txt  r.txt  t.txt  v.txt  x.txt  z.txt
$

I can use Zenity like this:

zenity --list --title=Test --width=275 --height=400 --column="File names" *.txt

and get this interface initially:

Zenity list

If I want to select a file lower down the list, say, r.txt, I press r and r.txt is selected.

Zenity showing selection

However, if I use Yad instead of Zenity like this:

yad --list --title=Test --width=275 --height=400 --column="File names" *.txt

pressing r does nothing. I have to use the arrow keys to scroll through the list until I come to r.txt.

My understanding is that Yad has more features than Zenity. So is there some way to get Yad to do what Zenity does?

(Tested using the repository versions of Yad and Zenity found in 18.04 and 19.10.)

DK Bose
  • 42,548
  • 23
  • 127
  • 221
  • 2
    On phone but you designate any column as --searchable or something like that. I'll post a real answer when I get home. – WinEunuuchs2Unix Nov 04 '19 at 13:25
  • I would for sure use rofi (or dmenu) for such user case. It has a fantastic quick search that narrows quickly down based on substrings you type. I use it for inserting custom text snippets among others. – vanadium Nov 04 '19 at 17:12
  • @DKBose Answer posted. Sorry for delay, but going to work pays for computers needed to answer questions :) – WinEunuuchs2Unix Nov 05 '19 at 00:19
  • @vanadium I haven't heard of either package before and would like to learn more. If you post an answer ping me and I'll upvote it. Thanks. – WinEunuuchs2Unix Nov 05 '19 at 02:45
  • BTW, I came across this which uses yad to deal with snippets. – DK Bose Nov 07 '19 at 10:31

1 Answers1

3

For learning yad I found this great reference: YAD - Smokey01.com

As mentioned in comments you want to use the option --search-column=N

Take the following code snippet as an example:

while true ; do
    local Selected INSTRUCTIONS
    INSTRUCTIONS="Click Icon to move and press Enter"
    Selected=$(yad --list --radiolist \
    --image="$ICON" --window-icon="$ICON" \
    --margins=10 --no-click  --search-column=4 \
    --title="$TITLE" "${GEOMETRY[@]}" \
    --text="<big><b>$TEXT</b></big> - $INSTRUCTIONS" \
    --column "Select" \
    --column "Order" \
    --column "Icon Type:HD" \
    --column "Icon name" \
    --column "Linkless name:HD" \
    --column "Modified date" \
    --column "Col Pos:NUM" \
    --column "Row Pos:NUM" \
    --button="_Alpha Sort:$ButnAlpha" \
    --button="_Linkless Sort:$ButnLinkless" \
    --button="_Oldest Date:$ButnOldest" \
    --button="_Newest Date:$ButnNewest" \
    --button="_Test:$ButnTest"  \
    --button="_Apply:$ButnApply" \
    --button="_Cancel:$ButnCancel" \
    "${IconsArr[@]}")

    Retn="$?"

Columns #3 and #5 are hidden but they are still counted. We want to search on Icon Name so it is column #4 as recorded here:

    --margins=10 --no-click  --search-column=4 \

The short .gif clip below shows what happens when we type:

  • a, Backspace, b, Backspace, c, Backspace, e (then gif loops)

search column.gif