Difference between revisions of "XDG user directories"

From ArchWiki
Jump to: navigation, search
(typo, lk)
(xdg-user-dirs-update: Add revert to English Example from Xfce.)
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Desktop environments]]
 
[[Category:Desktop environments]]
{{i18n|xdg-user-dirs-update}}
+
User directories are a set of common directories such as downloads directory, music directory, documents directory, and so on. These directories can have special identifying icons and used internally by many applications such as [[GNOME#Nautilus|Nautilus]] and [[Thunar]] to determine where to look for files to be passed to the ''Create Document'' context menu, whereas the desktop directory is used by Xfdesktop to find ''.desktop'' files to be shown on the Desktop.
 
+
'''xdg-user-dirs-update''' is a desktop-independent tool for configuring the location of certain user directories. Many applications of various [[Desktop Environment|desktop environments]] use the directories specified by xdg-user-dirs-update internally.
+
  
 
== Installation ==
 
== Installation ==
xdg-user-dirs-update is part of the {{pkg|xdg-user-dirs}} package available in [extra].
+
[[Pacman|install]] package {{pkg|xdg-user-dirs}} from [[Official Repositories]].
  
 
== Configuration ==
 
== Configuration ==
 
=== The config file ===
 
=== The config file ===
{{ic|xdg-user-dirs}} uses a configuration file located at {{ic|~/.config/user-dirs.dir}}. Its format is as follows:
+
{{ic|xdg-user-dirs}} uses two files for configuration:
 +
* For all users : {{ic|/etc/xdg/user-dirs.defaults}}.
 +
* For one specific user: {{ic|~/.config/user-dirs.dirs}}.  
 +
 
 +
Its format is as follows:
 
   XDG_DIRNAME_DIR="$HOME/Dirname"
 
   XDG_DIRNAME_DIR="$HOME/Dirname"
  
Line 22: Line 24:
 
   XDG_PICTURES_DIR="$HOME/Pictures"
 
   XDG_PICTURES_DIR="$HOME/Pictures"
 
   XDG_VIDEOS_DIR="$HOME/Videos"
 
   XDG_VIDEOS_DIR="$HOME/Videos"
 +
 +
Pointing any of the above variables to {{ic|$HOME}} disables the respective directory (it won't be automatically created).
  
 
=== xdg-user-dirs-update ===
 
=== xdg-user-dirs-update ===
 +
'''xdg-user-dirs-update''' is a desktop-independent tool for configuring the location of certain user directories. It is run very early in the login phase. This program reads a configuration file, and a set of default directories. It then creates localized versions of these directories in the users home directory and sets up a config file in $(XDG_CONFIG_HOME)/user-dirs.dirs (XDG_CONFIG_HOME defaults to ~/.config) that applications can read to find these directories.
  
The contents of the configuration file can be modified directly with a call to {{ic|xdg-user-dirs-update}}.
+
As an example, command
As an example, {{ic|xdg-user-dirs-update --set TEMPLATES ~/.templates}} will set the {{ic|template}} directory
+
 
to the specified directory with respect to the current user's {{ic|$HOME}}:
+
xdg-user-dirs-update --set TEMPLATES ~/.templates
 +
 
 +
will set the {{ic|template}} directory to the specified directory with respect to the current user's {{ic|$HOME}}:
  
 
   XDG_TEMPLATES_DIR="$HOME/.templates"
 
   XDG_TEMPLATES_DIR="$HOME/.templates"
 +
 +
If you want to revert to English, run the following:
 +
$ LC_ALL=C xdg-user-dirs-update
  
 
== xdg-user-dir ==
 
== xdg-user-dir ==
Line 38: Line 48:
  
 
will show the template directory, which of course corresponds to the {{ic|XDG_TEMPLATES_DIR}} variable in the config file.
 
will show the template directory, which of course corresponds to the {{ic|XDG_TEMPLATES_DIR}} variable in the config file.
 
== Applications using user directories ==
 
 
User directories are used internally by many applications: For instance, the template directory is used by [[GNOME#Nautilus|Nautilus]]
 
and [[Thunar]] to determine where to look for files to be passed to the ''Create Document'' context menu, whereas the desktop directory is used by Xfdesktop to find ''.desktop'' files to be shown on the Desktop.
 
  
 
== External Resource ==
 
== External Resource ==
 
* [http://freedesktop.org/wiki/Software/xdg-user-dirs xdg-user-dirs] - freedesktop.org
 
* [http://freedesktop.org/wiki/Software/xdg-user-dirs xdg-user-dirs] - freedesktop.org

Revision as of 15:13, 14 December 2012

User directories are a set of common directories such as downloads directory, music directory, documents directory, and so on. These directories can have special identifying icons and used internally by many applications such as Nautilus and Thunar to determine where to look for files to be passed to the Create Document context menu, whereas the desktop directory is used by Xfdesktop to find .desktop files to be shown on the Desktop.

Installation

install package xdg-user-dirs from Official Repositories.

Configuration

The config file

xdg-user-dirs uses two files for configuration:

  • For all users : /etc/xdg/user-dirs.defaults.
  • For one specific user: ~/.config/user-dirs.dirs.

Its format is as follows:

 XDG_DIRNAME_DIR="$HOME/Dirname"

A complete file might 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"

Pointing any of the above variables to $HOME disables the respective directory (it won't be automatically created).

xdg-user-dirs-update

xdg-user-dirs-update is a desktop-independent tool for configuring the location of certain user directories. It is run very early in the login phase. This program reads a configuration file, and a set of default directories. It then creates localized versions of these directories in the users home directory and sets up a config file in $(XDG_CONFIG_HOME)/user-dirs.dirs (XDG_CONFIG_HOME defaults to ~/.config) that applications can read to find these directories.

As an example, command

xdg-user-dirs-update --set TEMPLATES ~/.templates

will set the template directory to the specified directory with respect to the current user's $HOME:

 XDG_TEMPLATES_DIR="$HOME/.templates"

If you want to revert to English, run the following:

$ LC_ALL=C xdg-user-dirs-update

xdg-user-dir

Once set, any user directory can be viewed with xdg-user-dir. For example:

$ xdg-user-dir TEMPLATES

will show the template directory, which of course corresponds to the XDG_TEMPLATES_DIR variable in the config file.

External Resource