NAME
Desktop::Open - Open a file or URL in the user's preferred application
VERSION
This document describes version 0.003 of Desktop::Open (from Perl
distribution Desktop-Open), released on 2023-10-21.
SYNOPSIS
use Desktop::Open qw(open_desktop);
my $ok = open_desktop($path_or_url);
# !defined($ok); no recognized command found
# $ok == 0; command found and executed
# $ok != 0; command found, error while executing
DESCRIPTION
This module tries to open specified file or URL in the user's preferred
application. Here's how it does it.
1. If on Windows, use "start". If on other OS, use "xdg-open" if
available.
2. If #1 fails, resort to using Browser::Open's "open_browser". Return
its return value. An exception is if #1 fails with "file/URL does not
exist" error, in which case we give up immediately.
TODO: On OSX, use "openit". Any taker?
FUNCTIONS
open_desktop
ENVIRONMENT
PERL_DESKTOP_OPEN_USE_BROWSER
Integer. If set to 1, then will just use Browser::Open directly instead
of xdg-open program.
HOMEPAGE
Please visit the project's homepage at
<https://metacpan.org/release/Desktop-Open>.
SOURCE
Source repository is at
<https://github.com/perlancar/perl-Desktop-Open>.
SEE ALSO
Browser::Open, on which our module is modelled upon.
Open::This also tries to do "The Right Thing" when opening files, but
it's heavily towards text editor and git/GitHub.
App::Open and its CLI openit also attempt to open file using appropriate
file. It requires setting up a configuration file to run.
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull
requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You
can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally
on your system), you can install Dist::Zilla,
Dist::Zilla::PluginBundle::Author::PERLANCAR,
Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2023, 2021 by perlancar
<perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
BUGS
Please report any bugs or feature requests on the bugtracker website
<https://rt.cpan.org/Public/Dist/Display.html?Name=Desktop-Open>
When submitting a bug or request, please include a test-file or a patch
to an existing test-file that illustrates the bug or desired feature.