File::UserDirs(3)
π File::UserDirs π
okay so this is a Perl manual page from the User Contributed Perl Documentation section β the module is called File::UserDirs and it is genuinely the most helpful little thing. it's here to help you find extra media and documents directories π
β¨ NAME β¨
File::UserDirs β find extra media and documents directories ποΈ
πΈ VERSION πΈ
version 0.09 β yes bestie, it's on 0.09, and it slays.
π¦ SYNOPSIS π¦
the whole vibe in three lines:
use File::UserDirs qw(:all);
print xdg_desktop_dir; # e.g. /home/user/Desktop
that's it. that's the whole thing. no cap. π
π DESCRIPTION π
so like β this module is your go-to for tracking down the directories that the Freedesktop.org xdg-user-dirs software kinda-sorta-formally specifies. it gives you a whole mechanism to locate those extra directories for your media and documents files. it's giving "organized friend who actually knows where the Downloads folder is" energy β¨
π§ FUNCTIONS π§
bestie listen β these can be exported on request. and there's also the group :all defined, which exports all the methods. yes, all of them. the whole squad π«Ά
π xdg_desktop_dir
my $dir = xdg_desktop_dir;
returns the desktop directory. unless the user has changed it, this is the directory Desktop in the home directory. iconic default behavior, honestly. π»
π xdg_documents_dir
my $dir = xdg_documents_dir;
returns the documents directory. unless the user has changed it, this is the home directory. π
π xdg_download_dir
my $dir = xdg_download_dir;
returns the download directory. unless the user has changed it, this is the home directory. π₯
π¦ xdg_music_dir
my $dir = xdg_music_dir;
returns the music directory. unless the user has changed it, this is the home directory. π§
πΈ xdg_pictures_dir
my $dir = xdg_pictures_dir;
returns the pictures directory. unless the user has changed it, this is the home directory. πΈ
π xdg_publicshare_dir
my $dir = xdg_publicshare_dir;
returns the public share directory. unless the user has changed it, this is the home directory. π
β xdg_templates_dir
my $dir = xdg_templates_dir;
returns the templates directory. unless the user has changed it, this is the home directory. π
π₯ xdg_videos_dir
my $dir = xdg_videos_dir;
returns the videos directory. unless the user has changed it, this is the home directory. π¬
π notice how almost every single one defaults to the home directory? yeah. that's the move. the desktop one is the only diva who defaults to an actual subdirectory (Desktop). main character energy tbh.
π DIAGNOSTICS π
"xdg-user-dir" failed to start: %sβ oh no. the executablexdg-user-dircould not be run, most likely because it was not installed. checkDEPENDENCIESbelow, bestie, don't leave me hanging π
π§΅ CONFIGURATION AND ENVIRONMENT π§΅
so the user can specify where these directories live in the file $XDG_CONFIG_HOME/user-dirs.dirs. it's a shell file that sets a bunch of environment variables. cute, right? β¨
now β if you want to find the exact pathname from Perl, you run this:
use File::BaseDir qw(config_home);
print config_home('user-dirs.dirs');
literally so handy. iykyk. π«Ά
π Example customised user-dirs.dirs
here's what a fully customized one looks like β look at all these absolute queens reorganizing their whole filesystem:
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"
okay but "$HOME/Files/Document templates" with the space in it?? bold. we love a folder name with a space. π
π DEPENDENCIES π
this module requires the executable xdg-user-dir from the package xdg-user-dirs. you literally cannot run without it, fr fr.
source code is available from <http://cgit.freedesktop.org/xdg/xdg-user-dirs/> β go grab it if you don't have it π
π AUTHORS π
- Jaap Karssenberg || Pardus [Larus] <pardus@cpan.org>
- Graham Ollis <plicease@cpan.org>
two legends. we stan. π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2003-2021 by Jaap Karssenberg || Pardus [Larus] <pardus@cpan.org>.
and it's free software β you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. π
and that's the whole page, bestie! π¦ this one shipped as perl v5.42.2 on 2023-07-03 β so go forth, find those directories, and remember: the home directory default is not a bug, it's a lifestyle. πβ¨π
π¦ where this page comes from
- alpine 3.24: perl-file-basedir-doc 0.09-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms