diff --git a/src/config.py b/src/config.py index feb60ba5..5d585eb1 100644 --- a/src/config.py +++ b/src/config.py @@ -65,8 +65,8 @@ def load_data(self): self.configs["params"]["parser"].read("config/params.ini") self.configs["game"]["parser"].read(f"config/game_{Cam().res_key}.ini") - user = os.getlogin() - custom_params_path = Path(f"C:/Users/{user}/.d4lf/params.ini") + user_dir = os.path.expanduser("~") + custom_params_path = Path(f"{user_dir}/.d4lf/params.ini") if os.environ.get("RUN_ENV") != "test" and os.path.exists(custom_params_path): try: self.configs["custom"]["parser"].read(custom_params_path) diff --git a/src/item/filter.py b/src/item/filter.py index 1af03613..2b36db52 100644 --- a/src/item/filter.py +++ b/src/item/filter.py @@ -31,8 +31,8 @@ def load_files(self): self.files_loaded = True profiles: list[str] = Config().general["profiles"] - user = os.getlogin() - custom_profile_path = Path(f"C:/Users/{user}/.d4lf/profiles") + user_dir = os.path.expanduser("~") + custom_profile_path = Path(f"{user_dir}/.d4lf/profiles") params_profile_path = Path(f"config/profiles") for profile_str in profiles: diff --git a/src/main.py b/src/main.py index 3d1eda7c..9150d6b5 100644 --- a/src/main.py +++ b/src/main.py @@ -23,8 +23,8 @@ def main(): wait(0.2) # Create folders for logging stuff - user = os.getlogin() - config_dir = Path(f"C:/Users/{user}/.d4lf") + user_dir = os.path.expanduser("~") + config_dir = Path(f"{user_dir}/.d4lf") for dir_name in ["log/screenshots", config_dir, config_dir / "profiles"]: os.makedirs(dir_name, exist_ok=True) diff --git a/src/utils/game_settings.py b/src/utils/game_settings.py index b9361e10..873b79eb 100644 --- a/src/utils/game_settings.py +++ b/src/utils/game_settings.py @@ -5,7 +5,8 @@ def is_fontsize_ok() -> bool: custom_path = Config().general["local_prefs_path"] - default_path = f"C:\\Users\\{os.getlogin()}\\Documents\\Diablo IV/LocalPrefs.txt" + user_dir = os.path.expanduser("~") + default_path = f"{user_dir}\\Documents\\Diablo IV/LocalPrefs.txt" file_path = custom_path if custom_path != "" else default_path if not os.path.exists(file_path): Logger.warning("Could not find LocalPrefs.txt to check font size. Make sure you have font size set to small!")