[det]desktop_open(+Document)
- A URL, i.e., text for which uri_is_global/1
is true, such as
https://www.swi-prolog.orgormailto:bugs@example.com. The URL is passed to the opener unmodified. - A file or directory. This is either a plain file name, a term
Dir/File or a file alias such as
library(lists). If a plain file name does not exist as given it is expanded using expand_file_name/2, i.e.,~,$varand wildcards are expanded and all matching files are opened.
Options processed:
- opener(+Command)
- Use Command instead of the platform default. Command
is a specification for process_which/2,
a term
Command-Argsto pass the arguments Args before Document orwin_shellto use the Windows ShellExecute() API. - wait(+Boolean)
- If
true, wait for the opener to complete and raise an exception if it fails. This does not wait for the application: openers such asxdg-openmerely hand the document to the desktop and complete immediately, normally with success regardless of what the desktop does with it. Default isfalse, which starts the opener using thedetached(true)option of process_create/3. The option is ignored ifwin_shellis used, which never waits.
The command to use is taken from the first of these that yields an available command:
- The option
opener(Command) - The Prolog flag desktop_opener if it is not
default. It uses the same syntax as theopener(Command)option. - The Windows ShellExecute() API (see win_shell/2)
openon MacOScygstart(Cygwin),termux-open(Android/Termux) orwslview(WSL without a Linux desktop)xdg-open(freedesktop.org), followed by the desktop specificgio,gnome-open,kde-open,kde-open5andexo-openwslview,handlr,mimeopenorrun-mailcapopen, unless we are on Linux, whereopenis an alias foropenvt(1)rather than a document opener.
- Errors
- -
existence_error(source_sink, Document)if Document does not exist.
-existence_error(config, desktop_opener)if no command to open documents is available.
-process_error(Command, exit(Status))ifwait(true)is used and Command does not exit successfully.