Difference between revisions of "XDG user directories"

From ArchWiki
Jump to: navigation, search
m (Overview: remove title for aesthetic reasons.)
m (move information from summary to execution)
(One intermediate revision by the same user not shown)
Line 7: Line 7:
 
{{tip|This program will be especially helpful for those who wish to use a file manager to manage their desktop for a [[Window Manager]] such as [[Openbox]], as it will also automatically create a {{ic|~/Desktop}} directory.}}
 
{{tip|This program will be especially helpful for those who wish to use a file manager to manage their desktop for a [[Window Manager]] such as [[Openbox]], as it will also automatically create a {{ic|~/Desktop}} directory.}}
  
'''User directories''' are a set of common user directories located within a the {{ic|Home}} directory, including {{ic|Documents}}, {{ic|Downloads}}, {{ic|Music}}, and {{ic|Desktop}}. Identified by unique icons within a file manager, they will commonly be automatically sourced by numerous programs and applications. {{pkg|xdg-user-dirs}} is a program that will automatically generate these directories (see the [http://freedesktop.org/wiki/Software/xdg-user-dirs freedesktop.org] website for further information). When executed, it will also automatically:
+
'''User directories''' are a set of common user directories located within a the {{ic|Home}} directory, including {{ic|Documents}}, {{ic|Downloads}}, {{ic|Music}}, and {{ic|Desktop}}. Identified by unique icons within a file manager, they will commonly be automatically sourced by numerous programs and applications. {{pkg|xdg-user-dirs}} is a program that will automatically generate these directories (see the [http://freedesktop.org/wiki/Software/xdg-user-dirs freedesktop.org] website for further information).
 
+
* Match the [[Locale]] language settings when naming the directories, and
+
* Create a local {{ic|~/.config/user-dirs.dirs}} configuration file (i.e. for applications to find and use the directories)
+
* Create a global {{ic|/etc/xdg/user-dirs.defaults}} configuration file
+
  
 
== Installation ==
 
== Installation ==
 
[[Pacman|install]] package {{pkg|xdg-user-dirs}} from [[Official Repositories]].
 
[[Pacman|install]] package {{pkg|xdg-user-dirs}} from [[Official Repositories]].
  
== Creating Home directories ==
+
== Creating default Home directories ==
 
{{warning|As these directories are intended to be used for a local user account, do not execute the command provided as '''root'''.}}
 
{{warning|As these directories are intended to be used for a local user account, do not execute the command provided as '''root'''.}}
  
To create a full suite of user directories within the {{ic|Home}} directory, enter the following command:
+
To create a full suite of default user directories within the {{ic|Home}} directory, enter the following command:
  
 
  $ xdg-user-dirs-update
 
  $ xdg-user-dirs-update
 +
 +
When executed, it will also automatically:
 +
 +
* Create a local {{ic|~/.config/user-dirs.dirs}} configuration file (i.e. for applications to find and use home directories specific to an account)
 +
* Create a global {{ic|/etc/xdg/user-dirs.defaults}} configuration file (i.e. for applications to find and use home directories generally)
 +
* Create a local {{ic|~/.config/user-dirs.locale}} configuration file (i.e. to set the language used according to the locale used).
 +
 +
== Creating custom Home directories ==
 +
{{tip|As with any configuration file, local settings will always override global settings. It will also be necessary to manually create the custom {{ic|Home}} directories, where used (which may also be hidden files, if desired).}}
 +
Both the local {{ic|~/.config/user-dirs.dirs}} and global {{ic|/etc/xdg/user-dirs.defaults}} configuration files use the following format to point to {{ic|Home}} directories:
 +
 +
  XDG_DIRNAME_DIR="$HOME/<directory name>"
 +
 +
A complete configuration file may also contain multiple entries:
 +
 +
XDG_DESKTOP_DIR="$HOME/Desktop"
 +
XDG_DOWNLOAD_DIR="$HOME/Downloads"
 +
XDG_TEMPLATES_DIR="$HOME/Templates"
 +
XDG_PUBLICSHARE_DIR="$HOME/Public"
 +
XDG_DOCUMENTS_DIR="$HOME/Documents"
 +
XDG_MUSIC_DIR="$HOME/Music"
 +
XDG_PICTURES_DIR="$HOME/Pictures"
 +
XDG_VIDEOS_DIR="$HOME/Videos"
 +
 +
As {{pkg|xdg-user-dirs}} will source the local configuration file to point to the appropriate {{ic|Home}} directories, it is therefore possible to edit it in order specify custom folders. For example, in the following example, a custom folder for the {{ic|XDG_DOWNLOAD_DIR<nowiki>=</nowiki>}} variable has been created called {{ic|Internet}}, and {{ic|~/.config/user-dirs.dirs}} has been edited accordingly:
 +
 +
XDG_DOWNLOAD_DIR="$HOME/Internet"
 +
 +
Where downloading files from a web-browser, the default folder used for downloading will now be {{ic|Internet}}. Alternatively, it is also possible to specify custom folders using the command line. The syntax of this command is:
 +
 +
xdg-user-dirs-update --set <XDG NAME> <path/to/custom folder>
 +
 +
For example, the following command will produce the same results as the above configuration file edit:
 +
 +
xdg-user-dirs-update --set DOWNLOAD ~/Internet
 +
 +
The names of the {{ic|xdg}} templates are {{ic|DESKTOP}}, {{ic|DOWNLOAD}}, {{ic|TEMPLATES}}, {{ic|PUBLICSHARE}}, {{ic|DOCUMENTS}}, {{ic|MUSIC}}, {{ic|PICTURES}}, and {{ic|VIDEOS}}.
 +
 +
== Locating Home directories ==
 +
 +
Once set, any user directory can be viewed with {{pkg|xdg-user-dir}}. For example, the following command will specify the location of the {{ic|Templates}} directory, which of course corresponds to the  {{ic|XDG_TEMPLATES_DIR<nowiki>=</nowiki>}} variable in the local configuration file:
 +
 +
$ xdg-user-dir TEMPLATES

Revision as of 21:35, 2 December 2013

Tip: This program will be especially helpful for those who wish to use a file manager to manage their desktop for a Window Manager such as Openbox, as it will also automatically create a ~/Desktop directory.

User directories are a set of common user directories located within a the Home directory, including Documents, Downloads, Music, and Desktop. Identified by unique icons within a file manager, they will commonly be automatically sourced by numerous programs and applications. xdg-user-dirs is a program that will automatically generate these directories (see the freedesktop.org website for further information).

Installation

install package xdg-user-dirs from Official Repositories.

Creating default Home directories

Warning: As these directories are intended to be used for a local user account, do not execute the command provided as root.

To create a full suite of default user directories within the Home directory, enter the following command:

$ xdg-user-dirs-update

When executed, it will also automatically:

  • Create a local ~/.config/user-dirs.dirs configuration file (i.e. for applications to find and use home directories specific to an account)
  • Create a global /etc/xdg/user-dirs.defaults configuration file (i.e. for applications to find and use home directories generally)
  • Create a local ~/.config/user-dirs.locale configuration file (i.e. to set the language used according to the locale used).

Creating custom Home directories

Tip: As with any configuration file, local settings will always override global settings. It will also be necessary to manually create the custom Home directories, where used (which may also be hidden files, if desired).

Both the local ~/.config/user-dirs.dirs and global /etc/xdg/user-dirs.defaults configuration files use the following format to point to Home directories:

 XDG_DIRNAME_DIR="$HOME/<directory name>"

A complete configuration file may also contain multiple entries:

XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"

As xdg-user-dirs will source the local configuration file to point to the appropriate Home directories, it is therefore possible to edit it in order specify custom folders. For example, in the following example, a custom folder for the XDG_DOWNLOAD_DIR= variable has been created called Internet, and ~/.config/user-dirs.dirs has been edited accordingly:

XDG_DOWNLOAD_DIR="$HOME/Internet"

Where downloading files from a web-browser, the default folder used for downloading will now be Internet. Alternatively, it is also possible to specify custom folders using the command line. The syntax of this command is:

xdg-user-dirs-update --set <XDG NAME> <path/to/custom folder>

For example, the following command will produce the same results as the above configuration file edit:

xdg-user-dirs-update --set DOWNLOAD ~/Internet

The names of the xdg templates are DESKTOP, DOWNLOAD, TEMPLATES, PUBLICSHARE, DOCUMENTS, MUSIC, PICTURES, and VIDEOS.

Locating Home directories

Once set, any user directory can be viewed with xdg-user-dir. For example, the following command will specify the location of the Templates directory, which of course corresponds to the XDG_TEMPLATES_DIR= variable in the local configuration file:

$ xdg-user-dir TEMPLATES