about summary refs log tree commit diff stats
path: root/pkgs/by-name/qu/qutebrowser-patched/0001-fix-standardpaths-Continue-to-work-with-xdg-while-ba.patch
blob: fa2e248284d575acc58bb7cd743393cb3a8a862e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 8a0aa0e244fa565b8c55aab38cc5e84323c3b481 Mon Sep 17 00:00:00 2001
From: Benedikt Peetz <benedikt.peetz@b-peetz.de>
Date: Tue, 3 Jun 2025 12:43:44 +0200
Subject: [PATCH] fix(standardpaths): Continue to work with xdg, while
 `--basedir` is set

This can be used to simulate firefox's profiles feature (i.e., completely separated
data/runtime/cache dirs), while still keeping to the xdg basedir standard.
---
 qutebrowser/utils/standarddir.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py
index b82845a96..61319daed 100644
--- a/qutebrowser/utils/standarddir.py
+++ b/qutebrowser/utils/standarddir.py
@@ -285,12 +285,11 @@ def _from_args(
         The overridden path, or None if there is no override.
     """
     basedir_suffix = {
-        QStandardPaths.StandardLocation.ConfigLocation: 'config',
-        QStandardPaths.StandardLocation.AppDataLocation: 'data',
-        QStandardPaths.StandardLocation.AppLocalDataLocation: 'data',
-        QStandardPaths.StandardLocation.CacheLocation: 'cache',
-        QStandardPaths.StandardLocation.DownloadLocation: 'download',
-        QStandardPaths.StandardLocation.RuntimeLocation: 'runtime',
+        QStandardPaths.StandardLocation.ConfigLocation: ('config', False),
+        QStandardPaths.StandardLocation.AppDataLocation: ('data', False),
+        QStandardPaths.StandardLocation.AppLocalDataLocation: ('data', False),
+        QStandardPaths.StandardLocation.CacheLocation: ('cache', True),
+        QStandardPaths.StandardLocation.RuntimeLocation: ('runtime', True),
     }
 
     if getattr(args, 'basedir', None) is None:
@@ -298,10 +297,14 @@ def _from_args(
     assert args is not None
 
     try:
-        suffix = basedir_suffix[typ]
+        (suffix, extend) = basedir_suffix[typ]
     except KeyError:  # pragma: no cover
         return None
-    return os.path.abspath(os.path.join(args.basedir, suffix))
+
+    if extend:
+        return os.path.abspath(os.path.join(_writable_location(typ), os.path.basename(args.basedir)))
+    else:
+        return os.path.abspath(os.path.join(args.basedir, suffix))
 
 
 def _create(path: str) -> None:
-- 
2.49.0