{"id":6841,"date":"2022-12-20T19:33:43","date_gmt":"2022-12-20T22:33:43","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/filedesktopentry-man3\/"},"modified":"2022-12-20T19:33:43","modified_gmt":"2022-12-20T22:33:43","slug":"filedesktopentry-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/filedesktopentry-man3\/","title":{"rendered":"File::DesktopEntry (man3)"},"content":{"rendered":"<h1 align=\"center\">File::DesktopEntry<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#VARIABLES\">VARIABLES<\/a><br \/> <a href=\"#AUTOLOAD\">AUTOLOAD<\/a><br \/> <a href=\"#METHODS\">METHODS<\/a><br \/> <a href=\"#NON-UNIX PLATFORMS\">NON-UNIX PLATFORMS<\/a><br \/> <a href=\"#LIMITATIONS\">LIMITATIONS<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#LICENSE\">LICENSE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">File::DesktopEntry \u2212 Object to handle .desktop files<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">use File::DesktopEntry; <br \/> my $entry = File::DesktopEntry\u2212>new(&#8216;firefox&#8217;); <br \/> print &#8220;Using &#8220;.$entry\u2212>Name.&#8221; to open http:\/\/perl.orgn&#8221;; <br \/> $entry\u2212>run(&#8216;http:\/\/perl.org&#8217;);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This module is designed to work with <i>.desktop<\/i> files. The format of these files is specified by the freedesktop &#8220;Desktop Entry&#8221; specification. This module can parse these files but also knows how to run the applications defined by these files.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For this module version 1.0 of the specification was used.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This module was written to support File::MimeInfo::Applications.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Please remember: case is significant for the names of Desktop Entry keys.<\/p>\n<h2>VARIABLES <a name=\"VARIABLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">You can set the global variable $File::DesktopEntry::VERBOSE. If set the module prints a warning every time a command gets executed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The global variable $File::DesktopEntry::LOCALE tells you what the default locale being used is. However, changing it will not change the default locale.<\/p>\n<h2>AUTOLOAD <a name=\"AUTOLOAD\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">All methods that start with a capital are autoloaded as &#8220;get(KEY)&#8221; where key is the autoloaded method name.<\/p>\n<h2>METHODS <a name=\"METHODS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">&#8220;new(FILE)&#8221; <br \/> &#8220;new($TEXT)&#8221; <br \/> &#8220;new(NAME)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Constructor. <small>FILE, NAME<\/small> or <small>TEXT<\/small> are optional arguments.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">When a name is given (a string without \u2019&#8221;\/&#8221;\u2019, \u2019&#8221;&#8221;\u2019 or \u2019&#8221;.&#8221;\u2019) a lookup is done using File::BaseDir. If the file found in this lookup is not writable or if no file was found, the <small>XDG_DATA_HOME<\/small> path will be used when writing.<\/p>\n<p style=\"margin-left:11%;\">&#8220;lookup(NAME)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Returns a filename for a desktop entry with desktop file id <small>NAME.<\/small><\/p>\n<p style=\"margin-left:11%;\">&#8220;wants_uris( )&#8221;<\/p>\n<p style=\"margin-left:17%;\">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 <small>VFS<\/small> library.<\/p>\n<p style=\"margin-left:11%;\">&#8220;wants_list( )&#8221;<\/p>\n<p style=\"margin-left:17%;\">Returns true if the Exec string for this desktop entry specifies that the application can handle multiple arguments at once.<\/p>\n<p style=\"margin-left:11%;\">&#8220;run(@FILES)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Forks and runs the application specified in this Desktop Entry with arguments <small>FILES<\/small> as a background process. Returns the pid.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The child process fails when this is not a Desktop Entry of type Application or if the Exec key is missing or invalid.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If the desktop entry specifies that the program needs to be executed in a terminal the $TERMINAL environment variable is used. If this variable is not set &#8220;xterm \u2212e&#8221; is used as default.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">(On Windows this method returns a Win32::Process object.)<\/p>\n<p style=\"margin-left:11%;\">&#8220;system(@FILES)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Like &#8220;run()&#8221; but using the &#8220;system()&#8221; system call. It only return after the application has ended.<\/p>\n<p style=\"margin-left:11%;\">&#8220;exec(@FILES)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Like &#8220;run()&#8221; but using the &#8220;exec()&#8221; system call. This method is expected not to return but to replace the current process with the application you try to run.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">On Windows this method doesn\u2019t always work the way you want it to due to the &#8220;fork()&#8221; emulation on this platform. Try using &#8220;run()&#8221; or &#8220;system()&#8221; instead.<\/p>\n<p style=\"margin-left:11%;\">&#8220;parse_Exec(@FILES)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Expands the Exec format in this desktop entry with. Returns a properly quoted string in scalar context or a list of words in list context. Dies when the Exec key is invalid.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">It supports the following fields:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">%f single file <br \/> %F multiple files <br \/> %u single url <br \/> %U multiple urls <br \/> %i Icon field prefixed by \u2212\u2212icon <br \/> %c Name field, possibly translated <br \/> %k location of this .desktop file <br \/> %% literal &#8216;%&#8217;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If necessary this method tries to convert between paths and URLs but this is not perfect.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Fields that are deprecated, but (still) supported by this module:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">%d single directory <br \/> %D multiple directories<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The fields %n, %N, %v and %m are deprecated and will cause a warning if $VERBOSE is used. Any other unknown fields will cause an error.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The fields %F, %U, %D and %i can only occur as separate words because they expand to multiple arguments.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Also see &#8221; <small>LIMITATIONS&#8221;<\/small> .<\/p>\n<p style=\"margin-left:11%;\">&#8220;get(KEY)&#8221; <br \/> &#8220;get(GROUP, KEY)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Get a value for <small>KEY<\/small> from <small>GROUP.<\/small> If <small>GROUP<\/small> is not specified \u2019Desktop Entry\u2019 is used. All values are treated as string, so e.g. booleans will be returned as the literal strings &#8220;true&#8221; and &#8220;false&#8221;.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">When <small>KEY<\/small> does not contain a language code you get the translation in the current locale if available or a sensible default. The request a specific language you can add the language part. E.g. &#8220;$entry\u2212>get(&#8216;Name[nl_NL]&#8217;)&#8221; can return either the value of the \u2019Name[nl_NL]\u2019, the \u2019Name[nl]\u2019 or the \u2019Name\u2019 key in the Desktop Entry file. Exact language parsing order can be found in the spec. To force you get the untranslated key use either \u2019Name[C]\u2019 or \u2019Name[ <small>POSIX<\/small> ]\u2019.<\/p>\n<p style=\"margin-left:11%;\">&#8220;set(KEY => VALUE, &#8230;)&#8221; <br \/> &#8220;set(GROUP, KEY => VALUE, &#8230;)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Set values for one or more keys. If <small>GROUP<\/small> is not given &#8220;Desktop Entry&#8221; is used. All values are treated as strings, backslashes, newlines and tabs are escaped. To set a boolean key you need to use the literal strings &#8220;true&#8221; and &#8220;false&#8221;.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Unlike the &#8220;get()&#8221; call languages are not handled automatically for &#8220;set()&#8221;. <small>KEY<\/small> should include the language part if you want to set a translation. E.g. &#8220;$entry\u2212>set(&#8220;Name[nl_NL]&#8221; => &#8220;Tekst Verwerker&#8221;)&#8221; will set a Dutch translation for the Name key. Using either &#8220;Name[C]&#8221; or &#8220;Name[ <small>POSIX<\/small> ]&#8221; will be equivalent with not giving a language argument.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">When setting the Exec key without specifying a group it will be parsed and quoted correctly as required by the spec. You can use quoted arguments to include whitespace in a argument, escaping whitespace does not work. To circumvent this quoting explicitly give the group name \u2019Desktop Entry\u2019.<\/p>\n<p style=\"margin-left:11%;\">&#8220;text()&#8221;<\/p>\n<p style=\"margin-left:17%;\">Returns the (modified) text of the file.<\/p>\n<p style=\"margin-left:11%;\">&#8220;read(FILE)&#8221; <br \/> &#8220;read($SCALAR)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Read Desktop Entry data from file or memory buffer. Without argument defaults to file given at constructor.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If you gave a file, text buffer or name to the constructor this method will be called automatically.<\/p>\n<p style=\"margin-left:11%;\">&#8220;read_fh(IO)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Read Desktop Entry data from filehandle or <small>IO<\/small> object.<\/p>\n<p style=\"margin-left:11%;\">&#8220;write(FILE)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Write the Desktop Entry data to <small>FILE.<\/small> Without arguments it writes to the filename given to the constructor if any.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The keys Name and Type are required. Type can be either &#8220;Application&#8221;, &#8220;Link&#8221; or &#8220;Directory&#8221;. For an application set the optional key &#8220;Exec&#8221;. For a link set the &#8220;URL&#8221; key.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Backwards Compatibility<\/b> <br \/> Methods supported for backwards compatibility with 0.02. <br \/> &#8220;new_from_file(FILE)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Alias for &#8220;new(FILE)&#8221;.<\/p>\n<p style=\"margin-left:11%;\">&#8220;new_from_data(TEXT)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Alias for &#8220;new($TEXT)&#8221;.<\/p>\n<p style=\"margin-left:11%;\">&#8220;get_value(NAME, GROUP, LANG)&#8221;<\/p>\n<p style=\"margin-left:17%;\">Identical to &#8220;get(GROUP, &#8220;NAME[LANG]&#8221;)&#8221;. <small>LANG<\/small> defaults to \u2019C\u2019, <small>GROUP<\/small> is optional.<\/p>\n<h2>NON-UNIX PLATFORMS <a name=\"NON-UNIX PLATFORMS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This module has a few bits of code to make it work on Windows. It handles &#8220;file:\/\/&#8221; uri a bit different and it uses Win32::Process. On other platforms your mileage may vary.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Please note that the specification is targeting Unix platforms only and will only have limited relevance on other platforms. Any platform-dependent behavior in this module should be considered an extension of the spec.<\/p>\n<h2>LIMITATIONS <a name=\"LIMITATIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">If you try to exec a remote file with an application that can only handle files on the local file system we should \u2212according to the spec\u2212 download the file to a temp location. This is not supported. Use the &#8220;wants_uris()&#8221; method to check if an application supports urls.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The values of the various Desktop Entry keys are not parsed (except for the Exec key). This means that booleans will be returned as the strings &#8220;true&#8221; and &#8220;false&#8221; and lists will still be &#8220;;&#8221; separated.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the icon is given as name and not as path it should be resolved for the %i code in the Exec key. We need a separate module for the icon spec to deal with this.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">According to the spec comments can contain any encoding. However since this module read files as utf8, invalid <small>UTF\u22128<\/small> characters in a comment will cause an error.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There is no support for Legacy-Mixed Encoding. Everybody is using utf8 now &#8230; right ?<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Jaap Karssenberg (Pardus) <pardus@cpan.org><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Maintained by Michiel Beijen <michielb@cpan.org><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright (c) 2005, 2007 Jaap G Karssenberg. All rights reserved.<\/p>\n<h2>LICENSE <a name=\"LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This program is free software; you can redistribute it and\/or modify it under the same terms as Perl itself.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><http:\/\/standards.freedesktop.org\/desktop\u2212entry\u2212spec\/desktop\u2212entry\u2212spec\u2212latest.html><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">File::BaseDir and File::MimeInfo::Applications<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">X11::FreeDesktop::DesktopEntry<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  File::DesktopEntry \u2212 Object to handle .desktop files <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3206,3007],"class_list":["post-6841","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-filedesktopentry","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6841"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6841\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}