From 50f1ff3a555b925d2219e1ec606482e01796154e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 29 Oct 2022 23:51:46 +0200 Subject: [PATCH] Use proper users home even when in sudo --- sync.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sync.py b/sync.py index 9b78208..904c6cb 100755 --- a/sync.py +++ b/sync.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import annotations +import os import hashlib import sys 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) rich = None -DOTHOMEDIR = Path("./home") -HOMEDIR = Path("~") DOTROOTDIR = Path("./root") 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):