From d2e6f498a1df2469c52b5d5a274dc0920acd7758 Mon Sep 17 00:00:00 2001 From: seiuneko Date: Fri, 16 Feb 2024 21:31:58 +0800 Subject: [PATCH] feat: add dynamic pacman log path detection --- src/code/os_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/code/os_utils.py b/src/code/os_utils.py index a278eb2..d3c0b35 100644 --- a/src/code/os_utils.py +++ b/src/code/os_utils.py @@ -70,8 +70,16 @@ def is_btrfs_volume(mount_point: str) -> bool: return True +def get_pacman_log_path() -> str: + try: + return execute_sh("pacman-conf LogFile").strip() + except CommandError: + logging.warning("Unable to determine pacman log path. Using default.") + return "/var/log/pacman.log" + + def last_pacman_command() -> str: - logfile = "/var/log/pacman.log" + logfile = get_pacman_log_path() matcher = re.compile(r"\[[\d\-:T+]*\] \[PACMAN\] Running \'(?P.*)\'") with open(logfile) as f: for line in reversed(f.readlines()):