]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-path: expose XDG 'projects' user dir
authorLennart Poettering <lennart@amutable.com>
Mon, 20 Apr 2026 09:41:53 +0000 (11:41 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 20 Apr 2026 14:01:17 +0000 (15:01 +0100)
As per:

https://blog.tenstral.net/2026/04/hello-projects-directory.html

man/sd_path_lookup.xml
src/libsystemd/sd-path/sd-path.c
src/path/path-tool.c
src/systemd/sd-path.h
test/units/TEST-74-AUX-UTILS.path.sh

index 9190e6b00a49a15b593b8edbdfe1680e0143cb41..07592e71cebfccdf694f5d494a328361bc5a6b7f 100644 (file)
@@ -68,6 +68,7 @@
         <constant>SD_PATH_USER_PUBLIC</constant>,
         <constant>SD_PATH_USER_TEMPLATES</constant>,
         <constant>SD_PATH_USER_DESKTOP</constant>,
+        <constant>SD_PATH_USER_PROJECTS</constant>,
 
         <constant>SD_PATH_SEARCH_BINARIES</constant>,
         <constant>SD_PATH_SEARCH_BINARIES_DEFAULT</constant>,
index e009a71bea0fd901ee9539b4a816f1c4682e05d0..eebcd20b6f9c270e360b27e3522de282ff4f68e3 100644 (file)
@@ -282,6 +282,9 @@ static int get_path(uint64_t type, char **buffer, const char **ret) {
         case SD_PATH_USER_DESKTOP:
                 return from_xdg_user_dir("XDG_DESKTOP_DIR", buffer, ret);
 
+        case SD_PATH_USER_PROJECTS:
+                return from_xdg_user_dir("XDG_PROJECTS_DIR", buffer, ret);
+
         case SD_PATH_SYSTEMD_UTIL:
                 *ret = PREFIX_NOSLASH "/lib/systemd";
                 return 0;
index 797a7d06af89509bf8ccecbe5f33e8c13fe44387..1920ff8d60028d7d3224dbe3380627b7747f71f8 100644 (file)
@@ -61,6 +61,7 @@ static const char* const path_table[_SD_PATH_MAX] = {
         [SD_PATH_USER_PUBLIC]                                 = "user-public",
         [SD_PATH_USER_TEMPLATES]                              = "user-templates",
         [SD_PATH_USER_DESKTOP]                                = "user-desktop",
+        [SD_PATH_USER_PROJECTS]                               = "user-projects",
 
         [SD_PATH_SEARCH_BINARIES]                             = "search-binaries",
         [SD_PATH_SEARCH_BINARIES_DEFAULT]                     = "search-binaries-default",
index 2718cf82664755e3e4d1bf884a6a1f626cbfab1c..299fb20adea7256121c75e49009b87d62fb1fef1 100644 (file)
@@ -132,6 +132,8 @@ __extension__ enum {
         SD_PATH_USER_CREDENTIAL_STORE_ENCRYPTED,
         SD_PATH_USER_SEARCH_CREDENTIAL_STORE_ENCRYPTED,
 
+        SD_PATH_USER_PROJECTS,
+
         _SD_PATH_MAX,
         _SD_PATH_INVALID = UINT64_MAX
 };
index 4547f53e24d812a9df965ed1bce291780fa6546e..14f7ef8ec062bda1385c770942fb1b472dc07040 100755 (executable)
@@ -39,6 +39,7 @@ XDG_DOCUMENTS_DIR="$HOME/top/secret/documents"
 XDG_MUSIC_DIR="/tmp/vaporwave"
 XDG_PICTURES_DIR="$HOME/Pictures"
 XDG_VIDEOS_DIR="$HOME/🤔"
+XDG_PROJECTS_DIR="$HOME/my-projects"
 EOF
 
 systemd-path --help
@@ -66,12 +67,13 @@ assert_eq "$(systemd-path user-pictures)" "/root/Pictures"
 assert_eq "$(systemd-path user-public)" "/root/cat-pictures"
 assert_eq "$(systemd-path user-templates)" "/templates"
 assert_eq "$(systemd-path user-videos)" "/root/🤔"
+assert_eq "$(systemd-path user-projects)" "/root/my-projects"
 
 # Remove the user-dirs.dir file and check the defaults
 rm -fv "$USER_DIRS_CONF"
 [[ ! -e "$USER_DIRS_CONF" ]]
 assert_eq "$(systemd-path user-desktop)" "/root/Desktop"
-for dir in "" documents download music pictures public templates videos; do
+for dir in "" documents download music pictures public templates videos projects; do
     assert_eq "$(systemd-path "user${dir:+-$dir}")" "/root"
 done