summary refs log tree commit diff
path: root/pkgs/applications/window-managers/qtile/0002-Restore-PATH-and-PYTHONPATH.patch
blob: b620bfb25014404c562d4ca58445ba6a33066e12 (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
61
62
63
64
65
From f299a0aa0eefcf16bb4990f00ac3946727f43ef3 Mon Sep 17 00:00:00 2001
From: "Alexander V. Nikolaev" <avn@avnik.info>
Date: Fri, 27 Nov 2015 10:49:48 +0200
Subject: [PATCH 2/3] Restore PATH and PYTHONPATH

---
 bin/qtile         | 1 +
 bin/qtile-run     | 1 +
 bin/qtile-session | 2 ++
 libqtile/utils.py | 7 +++++++
 4 files changed, 11 insertions(+)

diff --git a/bin/qtile b/bin/qtile
index 66034fe..ce3fcd1 100755
--- a/bin/qtile
+++ b/bin/qtile
@@ -131,6 +131,7 @@ def make_qtile():
 
 
 if __name__ == "__main__":
+    __import__("importlib").import_module("libqtile.utils").restore_os_environment()
     rename_process()
     q = make_qtile()
     try:
diff --git a/bin/qtile-run b/bin/qtile-run
index ccedb96..646a476 100755
--- a/bin/qtile-run
+++ b/bin/qtile-run
@@ -50,6 +50,7 @@ def main():
     proc.wait()
 
 if __name__ == "__main__":
+    __import__("importlib").import_module("libqtile.utils").restore_os_environment()
     try:
         main()
     except KeyboardInterrupt:
diff --git a/bin/qtile-session b/bin/qtile-session
index 84f6a2d..da31b12 100755
--- a/bin/qtile-session
+++ b/bin/qtile-session
@@ -25,6 +25,8 @@
 Qtile session manager.
 """
 
+__import__("importlib").import_module("libqtile.utils").restore_os_environment()
+
 from libqtile.log_utils import init_log
 import logging
 import os
diff --git a/libqtile/utils.py b/libqtile/utils.py
index 284089b..ec3539e 100644
--- a/libqtile/utils.py
+++ b/libqtile/utils.py
@@ -227,3 +227,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