How to use the xdg.BaseDirectory.xdg_config_home function in xdg

To help you get started, we’ve selected a few xdg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kupferlauncher / kupfer / kupfer / plugin / documents.py View on Github external
def initialize(self):
        self.places_file = path.join(base.xdg_config_home, "gtk-3.0", "bookmarks")
github muflone / gnome-appfolders-manager / gnome_appfolders_manager / constants.py View on Github external
DIR_DOCS = os.path.join(DIR_PREFIX, 'doc')
else:
    DIR_PREFIX = os.path.join(sys.prefix, 'share', 'gnome-appfolders-manager')
    DIR_LOCALE = os.path.join(sys.prefix, 'share', 'locale')
    DIR_DOCS = os.path.join(sys.prefix, 'share', 'doc',
                            'gnome-appfolders-manager')
# Set the paths for the folders
DIR_DATA = os.path.join(DIR_PREFIX, 'data')
DIR_UI = os.path.join(DIR_PREFIX, 'ui')
try:
    # In read-only environments, the settings folder cannot be created
    # (eg in a Debian pbuilder fakeroot)
    DIR_SETTINGS = BaseDirectory.save_config_path(DOMAIN_NAME)
except:
    # Get the settings path without actually creating it
    DIR_SETTINGS = os.path.join(BaseDirectory.xdg_config_home, DOMAIN_NAME)
# Set the paths for the data files
FILE_ICON = os.path.join(DIR_DATA, 'gnome-appfolders-manager.png')
FILE_CONTRIBUTORS = os.path.join(DIR_DOCS, 'contributors')
FILE_TRANSLATORS = os.path.join(DIR_DOCS, 'translators')
FILE_LICENSE = os.path.join(DIR_DOCS, 'license')
FILE_RESOURCES = os.path.join(DIR_DOCS, 'resources')
# Set the paths for configuration files
FILE_SETTINGS = os.path.join(DIR_SETTINGS, 'settings.conf')
FILE_WINDOWS_POSITION = os.path.join(DIR_SETTINGS, 'windows.conf')
# Settings schema and paths
SCHEMA_FOLDERS = 'org.gnome.desktop.app-folders'
SCHEMA_FOLDER = '%s.folder' % SCHEMA_FOLDERS
github muflone / gespeaker / plugins / plugin_emesene / __init__.py View on Github external
def load(self):
    "Plugin load"
    GespeakerPlugin.load(self)
    # Warning! Emesene 1.6 uses absolute .config folder, not xdg config home
    self.plugins_path = os.path.join(
      xdg_config_home, 'emesene1.0', 'pluginsEmesene')
    self.plugin_filename = join(self.plugins_path, EMESENE_PLUGIN_FILENAME)
    if exists(self.plugins_path) and isdir(self.plugins_path):
      if exists(self.plugin_filename) or islink(self.plugin_filename):
        # Remove previous .py file
        os.remove(self.plugin_filename)
      if exists('%sc' % self.plugin_filename):
        # Remove previous .pyc file
        os.remove('%sc' % self.plugin_filename)
      # Symlink emesene
      os.symlink(
        join(__path__[0], EMESENE_PLUGIN_FILENAME),
        join(self.plugins_path, EMESENE_PLUGIN_FILENAME)
      )
github getting-things-gnome / gtg / GTG / core / __init__.py View on Github external
#=== IMPORT ====================================================================
import os
from xdg.BaseDirectory import xdg_data_home, xdg_config_home
from GTG.tools         import cleanxml
from configobj         import ConfigObj

from GTG.core          import firstrun_tasks

class CoreConfig:
    
    #The projects and tasks are of course DATA !
    #We then use XDG_DATA for them
    #Don't forget the "/" at the end.
    DATA_DIR  = os.path.join(xdg_data_home,'gtg/')
    DATA_FILE = "projects.xml"
    CONF_DIR = os.path.join(xdg_config_home,'gtg/')
    CONF_FILE = "gtg.conf"
    conf_dict = None
    #DBUS
    BUSNAME = "org.GTG"
    BUSINTERFACE = "/org/GTG"

    def __init__(self):
        if not os.path.exists(self.CONF_DIR) :
            os.makedirs(self.CONF_DIR)
        if not os.path.exists(self.DATA_DIR) :
            os.makedirs(self.DATA_DIR)
        if not os.path.exists(self.CONF_DIR + self.CONF_FILE):
            f = open(self.CONF_DIR + self.CONF_FILE, "w")
            f.close()
        self.conf_dict = ConfigObj(self.CONF_DIR + self.CONF_FILE)
github ju1ius / uxdgmenu / usr / lib / uxdgmenu / uxm / config.py View on Github external
PREFIX = "/usr"
SYSCONFDIR = "/etc"
#

PKG_NAME = "uxdgmenu"
APP_DAEMON = "uxm-daemon"
APP_WATCH = "uxdgmenud"
MENU_FILE = "uxm-applications.menu"
ROOTMENU_FILE = "uxm-rootmenu.menu"

HOME = os.path.expanduser('~')
BOOKMARKS_FILE = os.path.join(HOME, '.gtk-bookmarks')
RECENT_FILES_FILE = get_recent_files_path()

CACHE_DIR = os.path.join(xdg.BaseDirectory.xdg_cache_home, PKG_NAME)
CONFIG_DIR = os.path.join(xdg.BaseDirectory.xdg_config_home, PKG_NAME)
DATA_DIR = os.path.join(xdg.BaseDirectory.xdg_data_home, PKG_NAME)

APP_DIRS = [d for d in xdg.BaseDirectory.load_data_paths('applications')]
DIR_DIRS = [d for d in xdg.BaseDirectory.load_data_paths('desktop-directories')]
MENU_DIRS = [
    os.path.join(SYSCONFDIR, 'xdg', 'menus'),
    os.path.join(CONFIG_DIR, 'menus')
]

SYSTEM_CONFIG_FILE = os.path.join(SYSCONFDIR, PKG_NAME, 'menu.conf')
USER_CONFIG_FILE = os.path.join(CONFIG_DIR, 'menu.conf')

CACHE_DB = os.path.join(CACHE_DIR, 'cache.db')
ICON_CACHE_PATH = os.path.join(CACHE_DIR, 'icons')
APPS_CACHE = os.path.join(CACHE_DIR, 'applications')
BOOKMARKS_CACHE = os.path.join(CACHE_DIR, 'bookmarks')
github bharadwaj-raju / libdesktop / libdesktop / directories.py View on Github external
else:
		if os.name == 'nt':
			import winreg
			config_homes.append(
				winreg.ExpandEnvironmentStrings('%LOCALAPPDATA%'))
			config_homes.append(
				os.path.join(
					winreg.ExpandEnvironmentStrings('%APPDATA%'),
					'Roaming'))
		else:
			if os.getenv('XDG_CONFIG_HOME'):
				config_homes.append(os.getenv('XDG_CONFIG_HOME'))
			else:
				try:
					from xdg import BaseDirectory
					config_homes.append(BaseDirectory.xdg_config_home)
				except ImportError:
					config_homes.append(os.path.expanduser('~/.config'))

				config_homes.append(os.path.expanduser('~'))

				if os.name == 'darwin':
					config_homes.append(os.path.expanduser('~/Library'))

	if program:
		def __find_homes(app, dirs):

			homes = []

			for home in dirs:
				if os.path.isdir(os.path.join(home, app)):
					homes.append(os.path.join(home, app))
github pulb / mailnag / Mailnag / configuration / configwindow.py View on Github external
def _delete_autostart(self):
		autostart_folder = os.path.join(bd.xdg_config_home, "autostart")
		autostart_file = os.path.join(autostart_folder, "mailnag.desktop")
		if os.path.exists(autostart_file):
			os.remove(autostart_file)
github infoxchange / docker-forklift / forklift / __init__.py View on Github external
# generated from configuration files
    add_argument('--zzzz', action='store_const', const=None,
                 help=argparse.SUPPRESS)

    return parser


class Forklift(object):
    """
    The main class.
    """

    services = forklift.services.register
    drivers = forklift.drivers.register

    CONFIG_DIR = os.path.join(xdg_config_home, 'forklift')

    def __init__(self, argv):
        """
        Parse the command line and set up the class.
        """

        # Parse the configuration from:
        # - implicit defaults
        # - project configuration file
        # - user configuration file
        # - user per-project configuration file
        # - command line

        options = self.implicit_configuration()

        # Get application_id
github Ulauncher / Ulauncher / ulauncher / utils / AutostartPreference.py View on Github external
def __init__(self):
        self._ulauncher_desktop = self._get_app_desktop()
        self._ulauncher_autostart_desktop = os.path.join(xdg_config_home, 'autostart', 'ulauncher.desktop')
github vorot93 / obozrenie / obozrenie / global_settings.py View on Github external
if is_run_from_git_workdir():
    ICON_PATH = os.path.join(ASSETS_DIR, 'icons', 'hicolor', 'scalable', 'apps', ICON_NAME + '.svg')
    ICON_NAME = None

SETTINGS_DIR = os.path.join(PROJECT_DIR, 'settings')
SETTINGS_INTERNAL_DIR = os.path.join(SETTINGS_DIR, 'internal')
SETTINGS_INTERNAL_BACKENDS_DIR = os.path.join(SETTINGS_INTERNAL_DIR, 'backends')
SETTINGS_DEFAULTS_DIR = os.path.join(SETTINGS_DIR, 'defaults')

COMMON_SETTINGS_FILE = "settings.toml"
GAME_SETTINGS_FILE = "games.toml"

DEFAULT_COMMON_SETTINGS_PATH = os.path.join(SETTINGS_DEFAULTS_DIR, COMMON_SETTINGS_FILE)
DEFAULT_GAME_SETTINGS_PATH = os.path.join(SETTINGS_DEFAULTS_DIR, GAME_SETTINGS_FILE)

PROFILE_PATH = os.path.join(BaseDirectory.xdg_config_home, 'obozrenie')

GAME_CONFIG_FILE = os.path.join(SETTINGS_INTERNAL_DIR, "game_lists.toml")

GEOIP_DATA_FILE = os.path.join(SYSTEM_DATA_DIR, 'GeoIP', 'GeoIP.dat')

UI_DIR = os.path.join(PROJECT_DIR, "ui")
GTK_UI_FILE = os.path.join(UI_DIR, "obozrenie_gtk.ui")
GTK_APPMENU_FILE = os.path.join(UI_DIR, "obozrenie_gtk_appmenu.ui")