Skip to main content
xdg-user-dir -> xdg-user-dirs
Source Link
Arnie97
  • 265
  • 3
  • 10

The default path for the desktop directory varies between different languages. Hence a better guess than $HOME/Desktop could be fetchedobtained from xdg-user-dirsdir in case that exists inon your system:

$ xdg-user-dirsdir DESKTOP
/home/arnie97/桌面

(Note that the package name is xdg-user-dirs, while the executable name is xdg-user-dir. Thank @theDrake for pointing this out.)


There's also another way fromdescribed on the xdg-user-dirs home page, which unfortunately does not work on my system:

Here is a shellscript example of how to find the desktop and the download directory:

test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ${XDG_DOWNLOAD_DIR:-$HOME}

For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.

The default path for the desktop directory varies between different languages. Hence a better guess than $HOME/Desktop could be fetched from xdg-user-dirs in case that exists in your system:

$ xdg-user-dirs DESKTOP
/home/arnie97/桌面

There's also another way from xdg-user-dirs home page:

Here is a shellscript example of how to find the desktop and the download directory:

test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ${XDG_DOWNLOAD_DIR:-$HOME}

For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.

The default path for the desktop directory varies between different languages. Hence a better guess than $HOME/Desktop could be obtained from xdg-user-dir in case that exists on your system:

$ xdg-user-dir DESKTOP
/home/arnie97/桌面

(Note that the package name is xdg-user-dirs, while the executable name is xdg-user-dir. Thank @theDrake for pointing this out.)


There's also another way described on the xdg-user-dirs home page, which unfortunately does not work on my system:

Here is a shellscript example of how to find the desktop and the download directory:

test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ${XDG_DOWNLOAD_DIR:-$HOME}

For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.

Commonmark migration
Source Link

The default path for the desktop directory varies between different languages. Hence a better guess than $HOME/Desktop could be fetched from xdg-user-dirs in case that exists in your system:

$ xdg-user-dirs DESKTOP
/home/arnie97/桌面

There's also another way from xdg-user-dirs home page:

Here is a shellscript example of how to find the desktop and the download directory:

 
test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ${XDG_DOWNLOAD_DIR:-$HOME}
 

For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.

The default path for the desktop directory varies between different languages. Hence a better guess than $HOME/Desktop could be fetched from xdg-user-dirs in case that exists in your system:

$ xdg-user-dirs DESKTOP
/home/arnie97/桌面

There's also another way from xdg-user-dirs home page:

Here is a shellscript example of how to find the desktop and the download directory:

 
test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ${XDG_DOWNLOAD_DIR:-$HOME}
 

For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.

The default path for the desktop directory varies between different languages. Hence a better guess than $HOME/Desktop could be fetched from xdg-user-dirs in case that exists in your system:

$ xdg-user-dirs DESKTOP
/home/arnie97/桌面

There's also another way from xdg-user-dirs home page:

Here is a shellscript example of how to find the desktop and the download directory:

test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ${XDG_DOWNLOAD_DIR:-$HOME}

For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.

Source Link
Arnie97
  • 265
  • 3
  • 10

The default path for the desktop directory varies between different languages. Hence a better guess than $HOME/Desktop could be fetched from xdg-user-dirs in case that exists in your system:

$ xdg-user-dirs DESKTOP
/home/arnie97/桌面

There's also another way from xdg-user-dirs home page:

Here is a shellscript example of how to find the desktop and the download directory:

test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ${XDG_DOWNLOAD_DIR:-$HOME}

For application code the hope is that the various desktops will integrate this and have a nice API to find these directories.