Desktop.jl
Desktop
— ModuleBasic GUI desktop interactions, such as opening a URL with a web browser.
Example:
using Desktop
if hasdesktop()
browse_url("https://julialang.org/")
else
@info("No desktop environment available")
end
Desktop.hasdesktop
— Functionhasdesktop()
Returns true
if the current process appears to have access to a graphical desktop environment and is therefore likely to succeed when invoking GUI functions or applications.
The algorithm used is a platform-dependent heuristic:
On Microsoft Windows: tests if the current process is running in a “windows station” called
WinSta0
On macOS: checks the has-graphic-access bit in the security session information of the calling process
On other platforms: checks if a non-empty environment variable
DISPLAY
orWAYLAND_DISPLAY
exists
It only checks the native GUI interface of the respective platform; e.g. an available X11 server will be ignored on Windows or macOS.
Desktop.browse_url
— Functionbrowse_url(url::AbstractString)
Attempts to launch a web browser to display the document available at the provided URL or filesystem path.
The success of this function depends on access to a GUI desktop environment.
See also: hasdesktop
, open_file
Desktop.open_file
— Functionopen_file(path::AbstractString)
Opens a file using a default application that the operating system or desktop environment associates with this file type.
The success of this function may depend on access to a GUI desktop environment.
See also: hasdesktop
, browse_url