1. Yad File Dialog

Command
yad --file
yad file
Figure 1. File dialog

1.1. --filename=FILENAME

The file selection options need to be prefixed by yad --file EG:

Command
yad --file --filename=/home/ingemar/hello.txt

The file /home/ingemar/hello.txt must exist.

This will select /home/ingemar/hello.txt

yad file filename
Figure 2. File dialog with pre selected file

1.2. --multiple

Allow multiple selection.

Command
yad --file --multiple
yad file multiple
Figure 3. File dialog with multiple selected files

Use the Ctrl or Shift keys when selecting.

It’s all well and good being able to bring up a file select dialog but it needs to be able to parse the information selected.

One way is to assign the file selection dialog to a variable like:

Code
CHOOSEFILE=$(yad --file)

To see how it works try selecting a graphics file in a script like this:

Code
#!/bin/sh
CHOOSEFILE=$(yad --file) \
ristretto $CHOOSEFILE

Make sure you make the script executable.

When you have choosen a fil in the dialok and klick on the OK button ristretto will star and show the selected picture.

yad file choosefile
Figure 4. File dialog with file selected
ristretto
Figure 5. Ristretto shows selected file

1.3. --directory

Activate directory-only selection

Command
yad --file --directory
yad file directory
Figure 6. File dialog for selecting only directories

Only directories will be selectable.

1.4. --save

Activate save mode.

Command
yad --file --save
yad file save
Figure 7. File dialog in save mode

This provides a way to save a file.
If you type test.txt in the name field and click on OK the output will be:
/home/ingemar/test.txt

1.5. --separator=STRING

Specify separator character when returning multiple filenames.
Default separator is`|`.

Example of new line separator
yad --file --multiple --separator='\n'
File dialog with multiple files selected

yad file separator

The result is
/home/ingemar/Dokument/YAD/Yad-guide-12/Info/help-all.txt
/home/ingemar/Dokument/YAD/Yad-guide-12/Info/help-app.txt
/home/ingemar/Dokument/YAD/Yad-guide-12/Info/help-calendar.txt

1.6. --file-filter=NAME | PATTERN1 PATTERN2

Add a filename filter.
NAME is a displayed filter name, PATTERN is a shell-style filename pattern (for example *.txt). This option may be used multiple times.

Command
yad --file --file-filter "Text files | *.txt *.text"

This will only show files with the file extensions txt and text.

yad file filter
Figure 8. File dialog with file-filter set to txt and text

1.7. --mime-filter=NAME | MIME1 MIME2 …​

Add a mime-type filter.
NAME is a displayed filter name, PATTERN is a name of mime type (for example text/plain). This option may be used multiple times.

Command
yad --file --mime-filter="HTML|text/html"

This will only show html files.

yad file mime html
Figure 9. File dialog with file-filter set to html files

1.8. --image-filter=[NAME]

Add filter for images supported by gdk-pixbuf library.
NAME in as optional name for this filter.

This will only show images.

Command
yad --file --image-filter=png
yad file image filter
Figure 10. File dialog with filter set to images

1.9. --add-preview

Add preview widget.
Preview images loads from normal (default) or large thumbnails.

Command
yad --file --add-preview
yad file preview
Figure 11. File dialog with preview

1.9.1. --large-preview

Use large previews by default.
This option can be permanently turned on through yad settings.

Command
yad --file --add-preview --large-preview
yad file large preview
Figure 12. File dialog with large preview
Note YAD doesn’t check mtime for thumbnailed images and doesn’t updates preview if origial file was changed after thumbnail was created.

1.10. --title=TEXT

Display a file selector with the title Select a file to remove. The file selected is returned on standard output.

Command
yad --file --title="Select a file to remove" --file-selection
yad file select
Figure 13. File dialog with title
Result
/home/ingemar/printlist

1.11. --window-icon=ICON

Set the window icon.

Command
yad --file --title="Select a file to remove" --file-selection --window-icon=gtk-delete
yad file select window icon
Figure 14. Notice the window icon

Back to YAD Guide