Desktop.jl

DesktopModule

Basic 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.hasdesktopFunction
hasdesktop()

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 or WAYLAND_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_urlFunction
browse_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_fileFunction
open_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