48 lines
1.9 KiB
Diff
48 lines
1.9 KiB
Diff
From d3ff26a72b28907599cc04b5d4537c4af05e2c52 Mon Sep 17 00:00:00 2001
|
|
From: Olivier Fourdan <ofourdan@redhat.com>
|
|
Date: Thu, 26 Sep 2024 08:46:19 +0200
|
|
Subject: [PATCH 1/2] wlheadless: Set sensible defaults for XDG dirs
|
|
|
|
The specification says:
|
|
|
|
| $XDG_DATA_HOME defines the base directory relative to which user-
|
|
| specific data files should be stored. If $XDG_DATA_HOME is either
|
|
| not set or empty, a default equal to $HOME/.local/share should be
|
|
| used.
|
|
|
|
And:
|
|
|
|
| If $XDG_DATA_DIRS is either not set or empty, a value equal to
|
|
| /usr/local/share/:/usr/share/ should be used.
|
|
|
|
Set the default values according to the specifications, so that the
|
|
configuration file can be found even if either or those environment
|
|
variables is not set.
|
|
|
|
See-also: https://specifications.freedesktop.org/basedir-spec/latest/index.html#variables
|
|
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
|
|
---
|
|
src/wlheadless/wlheadless_common.py | 6 ++++--
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/wlheadless/wlheadless_common.py b/src/wlheadless/wlheadless_common.py
|
|
index d056f3b..57ede5e 100644
|
|
--- a/src/wlheadless/wlheadless_common.py
|
|
+++ b/src/wlheadless/wlheadless_common.py
|
|
@@ -76,8 +76,10 @@ class WlheadlessCommon:
|
|
def get_compositor(self):
|
|
""" Read the configuration for the default compositor """
|
|
dirs = []
|
|
- dirs.extend(os.getenv('XDG_DATA_HOME', '').split(':'))
|
|
- dirs.extend(os.getenv('XDG_DATA_DIRS', '').split(':'))
|
|
+ xdg_data_home=os.getenv('HOME', '') + '/.local/share'
|
|
+ xdg_data_dirs='/usr/local/share/:/usr/share/'
|
|
+ dirs.extend(os.getenv('XDG_DATA_HOME', xdg_data_home).split(':'))
|
|
+ dirs.extend(os.getenv('XDG_DATA_DIRS', xdg_data_dirs).split(':'))
|
|
config = configparser.ConfigParser()
|
|
config.read([os.path.join(d, 'wlheadless', 'wlheadless.conf') for d in dirs])
|
|
return config.get('DEFAULT', 'Compositor', fallback = 'weston')
|
|
--
|
|
2.46.2
|
|
|