1File::MimeInfo::ApplicaUtsieornsC(o3n)tributed Perl DocuFmielnet:a:tMiiomneInfo::Applications(3)
2
3
4

NAME

6       File::MimeInfo::Applications - Find programs to open a file by mimetype
7

SYNOPSIS

9         use File::MimeInfo::Magic;
10         use File::MimeInfo::Applications;
11
12         my $file = '/foo/bar';
13         my $mimetype = mimetype($file)
14             || die "Could not find mimetype for $file\n";
15
16         my ($default, @other) = mime_applications($mimetype);
17
18         if (defined $default) {
19             $default->system($file)
20         }
21         else {
22                 # prompt user with choice from @others
23                 # ...
24         }
25

DESCRIPTION

27       This module tries to find applications that can open files with a
28       certain mimetype. This is done in the way suggested by the freedesktop
29       Desktop Entry specification. This module is intended to be compatible
30       with file managers and other applications that implement this
31       specification.
32
33       This module depends on File::DesktopEntry being installed.
34
35       To use this module effectively you need to have the desktop-file-utils
36       package from freedesktop and run update-desktop-database after
37       installing new .desktop files.  See
38       <http://www.freedesktop.org/wiki/Software/desktop-file-utils>.
39
40       At the moment of writing this module is compatible with the way
41       Nautilus (Gnome) and with Thunar (XFCE) handle applications for
42       mimetypes. I understand KDE is still working on implementing the
43       freedesktop mime specifications but will follow. At the very least all
44       perl applications using this module are using the same defaults.
45

EXPORT

47       All methods are exported by default.
48

METHODS

50       "mime_applications(MIMETYPE)"
51           Returns an array of File::DesktopEntry objects. The first is the
52           default application for this mimetype, the rest are applications
53           that say they can handle this mimetype.
54
55           If the first result is undefined there is no default application
56           and it is good practice to ask the user which application he wants
57           to use.
58
59       "mime_applications_all(MIMETYPE)"
60           Like "mime_applications()" but also takes into account applications
61           that can open mimetypes from which MIMETYPE inherits. Parent
62           mimetypes tell something about the data format, all code inherits
63           from text/plain for example.
64
65       "mime_applications_set_default(MIMETYPE, APPLICATION)"
66           Save a default application for this mimetype. This action will
67           affect other applications using the same mechanism to find a
68           default application.
69
70           APPLICATION can either be a File::DesktopEntry object or the
71           basename of a .desktop file.
72
73       "mime_applications_set_custom(MIMETYPE, COMMAND)"
74           Save a custom shell command as default application.  Generates a
75           DesktopEntry file on the fly and calls
76           "mime_applications_set_custom".  Returns the DesktopEntry object.
77
78           No checks are done at all on COMMAND.  It should however contain at
79           least one word.
80

NOTES

82       This module looks for associations files in the order specified in
83       version 1.0 of the MIME applications specification. It will also
84       attempt a last-resort fallback to the legacy file
85       $XDG_DATA_HOME/applications/defaults.list. In all cases, it will only
86       write to the recommended per-user defaults file located at
87       $XDG_CONFIG_HOME/mimeapps.list.
88

AUTHOR

90       Jaap Karssenberg <pardus@cpan.org> Maintained by Michiel Beijen
91       <michiel.beijen@gmail.com>
92
94       Copyright (c) 2005, 2012 Jaap G Karssenberg. All rights reserved.  This
95       program is free software; you can redistribute it and/or modify it
96       under the same terms as Perl itself.
97

SEE ALSO

99       File::DesktopEntry, File::MimeInfo, File::MimeInfo::Magic,
100       File::BaseDir
101
102       <http://freedesktop.org/wiki/Software/desktop-file-utils/>
103       <http://freedesktop.org/wiki/Specifications/mime-apps-spec/>
104
105
106
107perl v5.32.0                      2020-07-28   File::MimeInfo::Applications(3)
Impressum