Linux Desktop – Get user directories (python)

How to get special user directories in Linux.

Check the PyGObject API Reference or the official Gtk Docs website for more info.

from gi.repository import GLib
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP)
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOCUMENTS)
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOWNLOAD)
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PUBLIC_SHARE)
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_TEMPLATES)
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_VIDEOS)

enum GLib.UserDirectoryDescription
DIRECTORY_DESKTOPThe user’s Desktop directory.
DIRECTORY_DOCUMENTSThe user’s Documents directory.
DIRECTORY_DOWNLOADThe user’s Downloads directory.
DIRECTORY_MUSICThe user’s Music directory.
DIRECTORY_PICTURESThe user’s Pictures directory.
DIRECTORY_PUBLIC_SHAREThe user’s shared directory.
DIRECTORY_TEMPLATESThe user’s Templates directory.
DIRECTORY_VIDEOSThe user’s Movies directory.

Leave a Reply

Your email address will not be published. Required fields are marked *