Use proper users home even when in sudo

This commit is contained in:
ItsDrike 2022-10-29 23:51:46 +02:00
parent ede00ca602
commit 50f1ff3a55
No known key found for this signature in database
GPG key ID: B014E761034AF742

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import annotations from __future__ import annotations
import os
import hashlib import hashlib
import sys import sys
from collections.abc import Iterable, Iterator from collections.abc import Iterable, Iterator
@ -14,10 +15,10 @@ except ImportError:
print("rich not found (`pip install rich`), falling back to no colors", file=sys.stderr) print("rich not found (`pip install rich`), falling back to no colors", file=sys.stderr)
rich = None rich = None
DOTHOMEDIR = Path("./home")
HOMEDIR = Path("~")
DOTROOTDIR = Path("./root") DOTROOTDIR = Path("./root")
ROOTDIR = Path("/") ROOTDIR = Path("/")
DOTHOMEDIR = Path("./home")
HOMEDIR = Path(f"~{os.environ.get('SUDO_USER', os.getlogin())}") # Make sure we use correct home even in sudo
class DiffStatus(Enum): class DiffStatus(Enum):