1DesktopEntry(3)       User Contributed Perl Documentation      DesktopEntry(3)
2
3
4

NAME

6       File::DesktopEntry - Object to handle .desktop files
7

SYNOPSIS

9               use File::DesktopEntry;
10
11               my $entry = File::DesktopEntry->new_from_file(
12                       '/usr/share/applications/mozilla-firefox.desktop' );
13
14               # ...
15
16               die $entry->get_value('Name')." isn't an application\n"
17                       unless $entry->get_value('Type') eq 'Application';
18               print "Using ".$entry->get_value('Name')." to open http://perl.org\n";
19               unless (fork) { # child
20                       $entry->exec('http://perl.org');
21               }
22

DESCRIPTION

24       This module is used to work with .desktop files. The format of these
25       files is specified by the freedesktop "Desktp Entry" specification.
26       See <http://freedesktop.org/wiki/Standards_2fdesktop_2dentry_2dspec>.
27       For this module version 0.9.4 of the specification was used.
28
29       This module was written to support File::MimeInfo::Applications.
30
31       Please remember: case is significant, most key names contain capitals.
32

EXPORT

34       None by default.
35

METHODS

37       "new_from_file(PATH)"
38           Constructor for a desktop entry specified by file PATH.
39
40       "new_from_data(TEXT)"
41           Constructor for a desktop entry specified by the content of string
42           TEXT.
43
44       "hash( )"
45           Parse data from file or text. This method must be called after the
46           constructor if you intend to use the hash with raw data.
47
48           If you access the data with a method this routine will be called
49           automaticly.
50
51           This step is provided so that you can pass around desktop entry
52           objects without actually reading their content easily.
53
54       "get_value(NAME, GROUP, LOCALE)"
55           Returns the content of a field in the desktop entry.  Content is
56           not parsed, so boolean false returns as the string 'false'.
57
58           GROUP and LOCALE are optional.
59
60       "system(ARGV)"
61           Run the application specified by this desktop entry with arguments
62           ARGV.  This method uses the "system()" system call and will only
63           return after the application has ended.
64
65           This method of course fails if the current desktop entry doesn't
66           specify an application at all.
67
68           If the desktop entry specifies that the program needs to be exe‐
69           cuted in a terminal the $TERMINAL environment variable is used. If
70           this variable is not set xterm(1) is used.
71
72       "exec(ARGV)"
73           Like "system(ARGV)" but uses the "exec()" system call. This method
74           is expected not to return but to replace the current process with
75           the application you try to run.
76
77           This is usefull in combination with "fork()" to run background pro‐
78           cesses.
79
80       "wants_uris( )"
81           Returns true if the Exec string for this desktop entry specifies
82           that the application uses URIs instead of paths. This can be used
83           to determine whether an application uses a VFS library.
84
85       "wants_list( )"
86           Returns true if the Exec tring for this desktop entry specifies
87           that the application can handle multiple arguments at once.
88
89       "parse_Exec(ARGV)"
90           Returns a string to execute based on the Exec format in this desk‐
91           top entry.
92
93           If necessary this method tries to convert between paths and URLs
94           but this is not perfect.
95

LIMITATIONS

97       There is no support for Legacy-Mixed Encoding. Everybody is using utf8
98       now ... right ?
99
100       If you try to exec a remote file with an application that can only han‐
101       dle files on the local file system we should -according to the spec-
102       download the file to a temp location. How can this be implemented with
103       an api that allows control over this process?
104
105       This module only reads desktop files at the moment. Write support
106       should be added to allow people to use it to create new desktop files.
107       ( Make sure that comments are preserved when adding write support. )
108

AUTHOR

110       Jaap Karssenberg (Pardus) <pardus@cpan.org>
111
112       Copyright (c) 2005 Jaap G Karssenberg. All rights reserved.  This pro‐
113       gram is free software; you can redistribute it and/or modify it under
114       the same terms as Perl itself.
115

SEE ALSO

117       File::BaseDir, File::MimeInfo::Applications
118
119       X11::FreeDesktop::DesktopEntry
120
121
122
123perl v5.8.8                       2005-10-08                   DesktopEntry(3)
Impressum