diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:45:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:45:20 +0000 |
commit | ae1c76ff830d146d41e88d6fba724c0a54bce868 (patch) | |
tree | 3c354bec95af07be35fc71a4b738268496f1a1c4 /build-aux/meson | |
parent | Initial commit. (diff) | |
download | gnome-control-center-ae1c76ff830d146d41e88d6fba724c0a54bce868.tar.xz gnome-control-center-ae1c76ff830d146d41e88d6fba724c0a54bce868.zip |
Adding upstream version 1:43.6.upstream/1%43.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build-aux/meson')
-rw-r--r-- | build-aux/meson/find_xdg_file.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/build-aux/meson/find_xdg_file.py b/build-aux/meson/find_xdg_file.py new file mode 100644 index 0000000..8e12823 --- /dev/null +++ b/build-aux/meson/find_xdg_file.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import os +import sys + +def usage(): + print('Usage:') + print('find_xdg_file.py FILENAME') + print('') + print('Looks for FILENAME in the XDG data directories and returns if path if found') + +if len(sys.argv) != 2: + usage() + sys.exit(1) + +filename = sys.argv[1] + +data_home = os.getenv('XDG_DATA_HOME') +if not data_home or data_home == '': + data_home = os.path.join(os.path.expanduser("~"), "local", "share") + +data_dirs_str = os.getenv('XDG_DATA_DIRS') +if not data_dirs_str or data_dirs_str == '': + data_dirs_str = '/usr/local/share/:/usr/share/' + +dirs = [] +dirs += [ data_home ] +for _dir in data_dirs_str.split(':'): + dirs += [ _dir ] + +for _dir in dirs: + full_path = os.path.join(_dir, filename) + if os.path.exists(full_path): + print(full_path) + sys.exit(0) + +print(f"'{filename}' not found in XDG data directories") +sys.exit(1) |