1MimeInfo::Applications(U3s)er Contributed Perl DocumentatMiiomneInfo::Applications(3)
2
3
4
6 File::MimeInfo::Applications - Find programs to open a file by mimetype
7
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
27 This module tries to find applications that can open files with a cer‐
28 tain 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 specifi‐
31 cation.
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 <http://freedesktop.org/wiki/Soft‐
38 ware_2fdesktop_2dfile_2dutils>.
39
40 At the moment of writing this module is compatible with the way nau‐
41 tilus (Gnome) handles mimetypes and with thunar. I understand KDE is
42 still working on implementing the freedesktop mime specifications but
43 will follow. At the very least all perl applications using this module
44 are using the same defaults.
45
47 All methods are exported by default.
48
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 practise 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 mime‐
62 types tell something about the data format, all code inherits from
63 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 appliction.
69
70 APPLICATION can either be a File::DesktopEntry object or the base‐
71 name of a .desktop file.
72
74 At present the file with defaults is $XDG_DATA_HOME/applica‐
75 tions/defaults.list. This file is not specified in any spec and if it
76 gets standardized it should probably be located in $XDG_CONFIG_HOME.
77 For this module I tried to implement the status quo.
78
80 Please mail the author when you encounter any bugs.
81
83 Jaap Karssenberg ⎪⎪ Pardus [Larus] <pardus@cpan.org>
84
85 Copyright (c) 2005 Jaap G Karssenberg. All rights reserved. This pro‐
86 gram is free software; you can redistribute it and/or modify it under
87 the same terms as Perl itself.
88
90 File::DesktopEntry, File::MimeInfo, File::MimeInfo::Magic,
91 File::BaseDir
92
93 <http://freedesktop.org/wiki/Software_2fdesktop_2dfile_2dutils>
94
95
96
97perl v5.8.8 2005-10-03 MimeInfo::Applications(3)