<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package File::UserDirs;
use strict;
use warnings FATAL =&gt; 'all';
use IPC::System::Simple qw(capturex);
use parent qw(Exporter);

our $VERSION     = '0.08';
our %EXPORT_TAGS = (
    all =&gt; [
        qw(xdg_desktop_dir xdg_documents_dir xdg_download_dir xdg_music_dir
        xdg_pictures_dir xdg_publicshare_dir xdg_templates_dir xdg_videos_dir)
    ]);
our @EXPORT_OK = @{$EXPORT_TAGS{all}};


sub _xdg_user_dir {
    my ($purpose) = @_;
    my $dir = capturex 'xdg-user-dir', $purpose;
    chomp $dir;
    return $dir;
}

sub xdg_desktop_dir     {return _xdg_user_dir 'DESKTOP';}
sub xdg_documents_dir   {return _xdg_user_dir 'DOCUMENTS';}
sub xdg_download_dir    {return _xdg_user_dir 'DOWNLOAD';}
sub xdg_music_dir       {return _xdg_user_dir 'MUSIC';}
sub xdg_pictures_dir    {return _xdg_user_dir 'PICTURES';}
sub xdg_publicshare_dir {return _xdg_user_dir 'PUBLICSHARE';}
sub xdg_templates_dir   {return _xdg_user_dir 'TEMPLATES';}
sub xdg_videos_dir      {return _xdg_user_dir 'VIDEOS';}

1;

__END__

=head1 NAME

File::UserDirs - find extra media and documents directories

=head1 VERSION

This document describes File::UserDirs version C&lt;0.04&gt;.

=head1 SYNOPSIS

    use File::UserDirs qw(:all);
    print xdg_desktop_dir; # e.g. /home/user/Desktop

=head1 DESCRIPTION

This module can be used to find directories as informally specified
by the Freedesktop.org xdg-user-dirs software. This
gives a mechanism to locate extra directories for media and documents files.

=head1 INTERFACE

=over

=item C&lt;xdg_desktop_dir&gt;

Returns the desktop directory. Unless changed by the user,
this is the directory F&lt;Desktop&gt; in the home directory.

=item C&lt;xdg_documents_dir&gt;

Returns the documents directory. Unless changed by the user,
this is the home directory.

=item C&lt;xdg_download_dir&gt;

Returns the download directory. Unless changed by the user,
this is the home directory.

=item C&lt;xdg_music_dir&gt;

Returns the music directory. Unless changed by the user,
this is the home directory.

=item C&lt;xdg_pictures_dir&gt;

Returns the pictures directory. Unless changed by the user,
this is the home directory.

=item C&lt;xdg_publicshare_dir&gt;

Returns the public share directory. Unless changed by the user,
this is the home directory.

=item C&lt;xdg_templates_dir&gt;

Returns the templates directory. Unless changed by the user,
this is the home directory.

=item C&lt;xdg_videos_dir&gt;

Returns the videos directory. Unless changed by the user,
this is the home directory.

=back

=head1 EXPORTS

None by default, but any method can be exported on demand.
Also the group C&lt;:all&gt; is defined which exports all methods.

=head1 DIAGNOSTICS

=over

=item C&lt;"xdg-user-dir" failed to start: %s&gt;

The executable C&lt;xdg-user-dir&gt; could not be run, most likely because it was not
installed. See L&lt;/"DEPENDENCIES"&gt;.

=back

=head1 CONFIGURATION AND ENVIRONMENT

The location of the directories can be specified by the user in the file
F&lt;$XDG_CONFIG_HOME/user-dirs.dirs&gt;. It is a shell file setting a number of
environment variables. To find the exact pathname from Perl, run:

    use File::BaseDir qw(config_home);
    print config_home('user-dirs.dirs');

=head2 Example customised F&lt;user-dirs.dirs&gt;

    XDG_DESKTOP_DIR="$HOME/Workspace"
    XDG_DOCUMENTS_DIR="$HOME/Files"
    XDG_DOWNLOAD_DIR="$HOME/Files/Downloads"
    XDG_MUSIC_DIR="$HOME/Files/Audio"
    XDG_PICTURES_DIR="$HOME/Files/Images"
    XDG_PUBLICSHARE_DIR="$HOME/public_html"
    XDG_TEMPLATES_DIR="$HOME/Files/Document templates"
    XDG_VIDEOS_DIR="$HOME/Files/Video"

=head1 DEPENDENCIES

This module requires the executable F&lt;xdg-user-dir&gt; from the package
C&lt;xdg-user-dirs&gt;. Source code is available from
L&lt;http://cgit.freedesktop.org/xdg/xdg-user-dirs/&gt;.

=head1 SEE ALSO

</pre></body></html>