201 lines
5.4 KiB
HTML
201 lines
5.4 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of File::MimeInfo::Applications</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>File::MimeInfo::Applications</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2018-08-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
File::MimeInfo::Applications - Find programs to open a file by mimetype
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use File::MimeInfo::Magic;
|
|
use File::MimeInfo::Applications;
|
|
|
|
my $file = '/foo/bar';
|
|
my $mimetype = mimetype($file)
|
|
|| die "Could not find mimetype for $file\n";
|
|
|
|
my ($default, @other) = mime_applications($mimetype);
|
|
|
|
if (defined $default) {
|
|
$default->system($file)
|
|
}
|
|
else {
|
|
# prompt user with choice from @others
|
|
# ...
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This module tries to find applications that can open files
|
|
with a certain mimetype. This is done in the way suggested by
|
|
the freedesktop Desktop Entry specification. This module is
|
|
intended to be compatible with file managers and other applications that
|
|
implement this specification.
|
|
<P>
|
|
|
|
This module depends on File::DesktopEntry being installed.
|
|
<P>
|
|
|
|
To use this module effectively you need to have the desktop-file-utils
|
|
package from freedesktop and run update-desktop-database after installing
|
|
new .desktop files.
|
|
See <<A HREF="http://www.freedesktop.org/wiki/Software/desktop-file-utils">http://www.freedesktop.org/wiki/Software/desktop-file-utils</A>>.
|
|
<P>
|
|
|
|
At the moment of writing this module is compatible with the way Nautilus (Gnome)
|
|
and with Thunar (<FONT SIZE="-1">XFCE</FONT>) handle applications for mimetypes. I understand <FONT SIZE="-1">KDE</FONT>
|
|
is still working on implementing the freedesktop mime specifications but will
|
|
follow. At the very least all perl applications using this module are using
|
|
the same defaults.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>EXPORT</H2>
|
|
|
|
|
|
|
|
All methods are exported by default.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">"mime_applications(MIMETYPE)"<DD>
|
|
|
|
|
|
|
|
|
|
Returns an array of File::DesktopEntry objects. The first
|
|
is the default application for this mimetype, the rest are
|
|
applications that say they can handle this mimetype.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If the first result is undefined there is no default application
|
|
and it is good practice to ask the user which application he wants
|
|
to use.
|
|
<DT id="2">"mime_applications_all(MIMETYPE)"<DD>
|
|
|
|
|
|
|
|
|
|
Like <TT>"mime_applications()"</TT> but also takes into account applications that
|
|
can open mimetypes from which <FONT SIZE="-1">MIMETYPE</FONT> inherits. Parent mimetypes tell
|
|
something about the data format, all code inherits from text/plain for example.
|
|
<DT id="3">"mime_applications_set_default(MIMETYPE, APPLICATION)"<DD>
|
|
|
|
|
|
|
|
|
|
Save a default application for this mimetype. This action will
|
|
affect other applications using the same mechanism to find a default
|
|
application.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<FONT SIZE="-1">APPLICATION</FONT> can either be a File::DesktopEntry object or
|
|
the basename of a .desktop file.
|
|
<DT id="4">"mime_applications_set_custom(MIMETYPE, COMMAND)"<DD>
|
|
|
|
|
|
|
|
|
|
Save a custom shell command as default application.
|
|
Generates a DesktopEntry file on the fly and calls
|
|
<TT>"mime_applications_set_custom"</TT>.
|
|
Returns the DesktopEntry object.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
No checks are done at all on <FONT SIZE="-1">COMMAND.</FONT>
|
|
It should however contain at least one word.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
|
|
|
|
This module looks for associations files in the order specified in version 1.0
|
|
of the <FONT SIZE="-1">MIME</FONT> applications specification. It will also attempt a last-resort
|
|
fallback to the legacy file
|
|
<I></I>$XDG_DATA_HOME<I>/applications/defaults.list</I>. In all cases, it will only write
|
|
to the recommended per-user defaults file located at
|
|
<I></I>$XDG_CONFIG_HOME<I>/mimeapps.list</I>.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Jaap Karssenberg <<A HREF="mailto:pardus@cpan.org">pardus@cpan.org</A>>
|
|
Maintained by Michiel Beijen <<A HREF="mailto:michiel.beijen@gmail.com">michiel.beijen@gmail.com</A>>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (c) 2005, 2012 Jaap G Karssenberg. All rights reserved.
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the same terms as Perl itself.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
File::DesktopEntry,
|
|
File::MimeInfo,
|
|
File::MimeInfo::Magic,
|
|
File::BaseDir
|
|
<P>
|
|
|
|
<<A HREF="http://freedesktop.org/wiki/Software/desktop-file-utils/">http://freedesktop.org/wiki/Software/desktop-file-utils/</A>>
|
|
<<A HREF="http://freedesktop.org/wiki/Specifications/mime-apps-spec/">http://freedesktop.org/wiki/Specifications/mime-apps-spec/</A>>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="8"><A HREF="#lbAE">EXPORT</A><DD>
|
|
<DT id="9"><A HREF="#lbAF">METHODS</A><DD>
|
|
<DT id="10"><A HREF="#lbAG">NOTES</A><DD>
|
|
<DT id="11"><A HREF="#lbAH">AUTHOR</A><DD>
|
|
<DT id="12"><A HREF="#lbAI">COPYRIGHT</A><DD>
|
|
<DT id="13"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:43 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|