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       <http://www.freedesktop.org/wiki/Software/desktop-file-utils>.
40
41       At the moment of writing this module is compatible with the way
42       Nautilus (Gnome) and with Thunar (XFCE) handle applications for
43       mimetypes. I understand KDE is still working on implementing the
44       freedesktop mime specifications but will follow. At the very least all
45       perl applications using this module are using the same defaults.
46

EXPORT

48       All methods are exported by default.
49

METHODS

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

NOTES

83       At present the file with defaults is
84       $XDG_DATA_HOME/applications/defaults.list.  This file is not specified
85       in any freedesktop spec and if it gets standardized it should probably
86       be located in $XDG_CONFIG_HOME. For this module I tried to implement
87       the status quo.
88

BUGS

90       Please mail the author when you encounter any bugs.
91

AUTHOR

93       Jaap Karssenberg || Pardus [Larus] <pardus@cpan.org>
94
95       Copyright (c) 2005,2008 Jaap G Karssenberg. All rights reserved.  This
96       program is free software; you can redistribute it and/or modify it
97       under the same terms as Perl itself.
98

SEE ALSO

100       File::DesktopEntry, File::MimeInfo, File::MimeInfo::Magic,
101       File::BaseDir
102
103       <http://freedesktop.org/wiki/Software_2fdesktop_2dfile_2dutils>
104
105
106
107perl v5.12.0                      2010-05-01   File::MimeInfo::Applications(3)
Impressum