Bottomline: For listing gtk stock icons yad is not a good choice - unless the user has applied SFR's patch.
Let's try our luck with other images. For searching icons in my system I normally use SFR's excellent
Icon Finder. The only drawback: this thing can be terribly slow.
I tried yad as a faster alternative and was impressed by the speed. To be fair it does much less than Icon Finder, e.g. it does not sniff image dimensions and doesn't do any scaling. All images are rendered in their original size. On the other side it can do things Icon Finder can not, e.g. sorting by file size or name.
Basically it can be done with a one-liner, but I made it four
:
Code: Select all
#!/bin/bash
function showinrox { rox -s "$4" ;} ; export -f showinrox
IFS=";"
FOUND=$(find /usr/local/lib/X11/pixmaps -regextype gnu-awk -iregex ".*\.(png|jpg|gif|xpm)$" -printf "%p${IFS}%f${IFS}%s${IFS}%p${IFS}")
yad --list --dclick-action='sh -c "showinrox %s"' --editable --geometry=700x500 --column=icon:IMG --column=name --column=size:NUM --column=path $FOUND
IFS can be set to any character not used in the resulting file names, even a unicode character will do. This character is used in find's -printf argument to separate 4 output fields. Yad then uses this character to split FOUND, a huge one line string, into column fields. In principal it's possible not to (re)define IFS and pray that none of the file names includes a space, but let's keep it safe.
In the demo I use
/usr/local/lib/X11/pixmaps as the search directory. If this works try
/usr/local/lib/X11. This should find much more icons. Initially yad sorts them as
find found them, i.e. sorted by directories. Sorting by name will make it possible to easily compare similar or same name icons. Sorting by file size is also interesting.
It is possible to search more that one directory tree. Just add more search path e.g.
find /root /usr /mnt/home ....
The find command searches for files with typical extensions. Add more if you like, e.g. try svg. This may find some monster svg icons (why do they have to be so huge when they are scalable anyway?).
In yad I added the --editable option. This makes it possible to click on an icon path and copy it (or drag&drop it into an editor).
Double clicking on an image will jump to the image file in ROX. Yad passes all field values to the showinrox function, but only the 4th is of interest as it represents the full path.