man File::DesktopEntry () - Object to handle .desktop files
NAME
File::DesktopEntry - Object to handle .desktop files
SYNOPSIS
use File::DesktopEntry;
my $entry = File::DesktopEntry->new_from_file( '/usr/share/applications/mozilla-firefox.desktop' );
# ...
die $entry->get_value('Name')." isn't an application\n" unless $entry->get_value('Type') eq 'Application'; print "Using ".$entry->get_value('Name')." to open http://perl.org\n"; unless (fork) { # child $entry->exec('http://perl.org'); }
DESCRIPTION
This module is used to work with .desktop files. The format of these files is specified by the freedesktop Desktp Entry specification. See <http://freedesktop.org/wiki/Standards_2fdesktop_2dentry_2dspec>. For this module version 0.9.4 of the specification was used.
This module was written to support File::MimeInfo::Applications.
Please remember: case is significant, most key names contain capitals.
EXPORT
None by default.
METHODS
Constructor for a desktop entry specified by file PATH. Constructor for a desktop entry specified by the content of string TEXT. Parse data from file or text. This method must be called after the constructor if you intend to use the hash with raw data. If you access the data with a method this routine will be called automaticly. This step is provided so that you can pass around desktop entry objects without actually reading their content easily. Returns the content of a field in the desktop entry. Content is not parsed, so boolean false returns as the string 'false'. GROUP and LOCALE are optional. Run the application specified by this desktop entry with arguments ARGV. This method uses the CWsystem() system call and will only return after the application has ended. This method of course fails if the current desktop entry doesn't specify an application at all. If the desktop entry specifies that the program needs to be executed in a terminal the CW$TERMINAL environment variable is used. If this variable is not set xterm(1) is used. Like CWsystem(ARGV) but uses the CWexec() system call. This method is expected not to return but to replace the current process with the application you try to run. This is usefull in combination with CWfork() to run background processes. Returns true if the Exec string for this desktop entry specifies that the application uses URIs instead of paths. This can be used to determine whether an application uses a VFS library. Returns true if the Exec tring for this desktop entry specifies that the application can handle multiple arguments at once. Returns a string to execute based on the Exec format in this desktop entry. If necessary this method tries to convert between paths and URLs but this is not perfect.
LIMITATIONS
There is no support for Legacy-Mixed Encoding. Everybody is using utf8 now ... right ?
If you try to exec a remote file with an application that can only handle files on the local file system we should -according to the spec- download the file to a temp location. How can this be implemented with an api that allows control over this process?
This module only reads desktop files at the moment. Write support should be added to allow people to use it to create new desktop files. ( Make sure that comments are preserved when adding write support. )
AUTHOR
Jaap Karssenberg (Pardus) <pardus@cpan.org>
Copyright (c) 2005 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.
SEE ALSO
File::BaseDir, File::MimeInfo::Applications
X11::FreeDesktop::DesktopEntry