- Documentation
- Reference manual
- Packages
- SWI-Prolog C-library
- Introduction
- library(process): Create processes and redirect I/O
- library(desktop): Interact with the desktop environment
- library(filesex): Extended operations on files
- library(uid): User and group management on Unix systems
- library(syslog): Unix syslog interface
- library(socket): Network socket (TCP and UDP) library
- The stream_pool library
- library(uri): Process URIs
- CGI Support library
- Password encryption library
- library(uuid): Universally Unique Identifier (UUID) Library
- SHA* Secure Hash Algorithms
- library(md5): MD5 hashes
- library(hash_stream): Maintain a hash on a stream
- Memory files
- library(time): Time and alarm library
- library(unix): Unix specific operations
- Limiting process resources
- library(udp_broadcast): A UDP broadcast proxy
- library(prolog_stream): A stream with Prolog callbacks
- SWI-Prolog C-library
3 library(desktop): Interact with the desktop environment
This library provides access to the desktop environment of the user. Currently it only provides desktop_open/1,2, which hands a document over to the application the desktop associates with it.
- [det]desktop_open(+Document)
- [det]desktop_open(+Document, +Options)
- Open Document using the application the desktop associates
with it, e.g., a PDF viewer for a ‘.pdf` file or a file browser if
Document is a directory. Document is one of
- 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.
- A URL, i.e., text for which uri_is_global/1
is true, such as