summary refs log tree commit diff
path: root/pkgs/applications/window-managers/qtile/0002-Restore-PATH-and-PYTHONPATH.patch
blob: 7d184838fbaabde55eb850d0e5a8d14395c2bf82 (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
55
56
57
58
59
60
diff --git a/bin/qshell b/bin/qshell
index 2ba7e61c..0ac2a2ef 100755
--- a/bin/qshell
+++ b/bin/qshell
@@ -28,5 +28,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
 sys.path.insert(0, base_dir)
 
 if __name__ == '__main__':
+    __import__("importlib").import_module("libqtile.utils").restore_os_environment()
     from libqtile.scripts import qshell
     qshell.main()
diff --git a/bin/qtile b/bin/qtile
index 3e82814d..335b5cea 100755
--- a/bin/qtile
+++ b/bin/qtile
@@ -29,5 +29,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
 sys.path.insert(0, base_dir)
 
 if __name__ == '__main__':
+    __import__("importlib").import_module("libqtile.utils").restore_os_environment()
     from libqtile.scripts import qtile
     qtile.main()
diff --git a/bin/qtile-run b/bin/qtile-run
index e4b121be..1c203bc9 100755
--- a/bin/qtile-run
+++ b/bin/qtile-run
@@ -8,5 +8,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
 sys.path.insert(0, base_dir)
 
 if __name__ == '__main__':
+    __import__("importlib").import_module("libqtile.utils").restore_os_environment()
     from libqtile.scripts import qtile_run
     qtile_run.main()
diff --git a/bin/qtile-top b/bin/qtile-top
index 5316e0e7..272c6430 100755
--- a/bin/qtile-top
+++ b/bin/qtile-top
@@ -8,5 +8,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
 sys.path.insert(0, base_dir)
 
 if __name__ == '__main__':
+    __import__("importlib").import_module("libqtile.utils").restore_os_environment()
     from libqtile.scripts import qtile_top
     qtile_top.main()
diff --git a/libqtile/utils.py b/libqtile/utils.py
index 36ed0a58..bca9eab3 100644
--- a/libqtile/utils.py
+++ b/libqtile/utils.py
@@ -240,3 +240,11 @@ def describe_attributes(obj, attrs, func=None):
             pairs.append('%s=%s' % (attr, value))
 
     return ', '.join(pairs)
+
+
+def restore_os_environment():
+    pythonpath = os.environ.pop("QTILE_SAVED_PYTHONPATH", "")
+    os.environ["PYTHONPATH"] = pythonpath
+    path = os.environ.pop("QTILE_SAVED_PATH", None)
+    if path:
+        os.environ["PATH"] = path