From 9e37b6d5310813443106d579b6fa47f2e41a09ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=90=D0=B1?= =?UTF-8?q?=D0=B4=D1=80=D0=B0=D1=85=D0=BC=D0=B0=D0=BD=D0=BE=D0=B2?= <565963@gmail.com> Date: Wed, 16 Oct 2024 13:14:12 +0300 Subject: [PATCH] fix: auto-deploy conky conf --- services/conkyconf.service | 3 ++- src/fix.py | 6 +++--- src/installer.py | 23 +++++++++++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/services/conkyconf.service b/services/conkyconf.service index e8e0f13..3f8b931 100644 --- a/services/conkyconf.service +++ b/services/conkyconf.service @@ -6,7 +6,8 @@ After=conky.service Type=oneshot WorkingDirectory=/home/citrullux/ModernOSLabs/src ExecStart=/usr/bin/python3 /home/citrullux/ModernOSLabs/src/main.py -f -Restart=always +Restart=on-failure +RestartSec=30 [Install] WantedBy=default.target \ No newline at end of file diff --git a/src/fix.py b/src/fix.py index f30ef9d..0630b93 100644 --- a/src/fix.py +++ b/src/fix.py @@ -5,19 +5,19 @@ from time import sleep def config_desktop(lines: list, homeDir: Path) -> None: lines[44] = " own_window_type = 'desktop'," + "\n" - with open(os.path.join(homeDir, ".config/conky/conky.config"), "w") as config: + with open(os.path.join(homeDir, ".config/conky/conky.conf"), "w") as config: config.writelines(lines) def config_override(lines: list, homeDir: Path) -> None: lines[44] = " own_window_type = 'override'," + "\n" - with open(os.path.join(homeDir, ".config/conky/conky.config"), "w") as config: + with open(os.path.join(homeDir, ".config/conky/conky.conf"), "w") as config: config.writelines(lines) def conky_fix() -> None: homeDir = Path(os.getenv("HOME")) - with open(os.path.join(homeDir, ".config/conky/conky.config"), "r") as config: + with open(os.path.join(homeDir, ".config/conky/conky.conf"), "r") as config: lines = config.readlines() if lines[44] != " own_window_type = 'desktop'," + "\n": config_desktop(lines, homeDir) diff --git a/src/installer.py b/src/installer.py index 64cbb53..53c2270 100644 --- a/src/installer.py +++ b/src/installer.py @@ -11,17 +11,36 @@ def install() -> None: homeDir = Path(os.getenv("HOME")) # Service file change for userspace + pythonPath = ( + subprocess.check_output("which python3", shell=True).decode("utf-8").strip() + ) + + # Fix for weather service with open(os.path.join(projectDir, "services/wthrc.service"), "r") as service: lines = service.readlines() lines[5] = "WorkingDirectory=" + os.path.join(projectDir, "src") + "\n" lines[6] = ( - "ExecStart=/usr/bin/python3 " + os.path.join(projectDir, "src/main.py") + "\n" + "ExecStart=" + pythonPath + " " + os.path.join(projectDir, "src/main.py") + "\n" ) with open(os.path.join(projectDir, "services/wthrc.service"), "w") as service: service.writelines(lines) + # Fix for conky service + with open(os.path.join(projectDir, "services/conkyconf.service"), "r") as service: + lines = service.readlines() + lines[6] = "WorkingDirectory=" + os.path.join(projectDir, "src") + "\n" + lines[7] = ( + "ExecStart=" + + pythonPath + + " " + + os.path.join(projectDir, "src/main.py -f") + + "\n" + ) + with open(os.path.join(projectDir, "services/conkyconf.service"), "w") as service: + service.writelines(lines) + serviceDirExist = os.path.isdir(os.path.join(homeDir, ".config/systemd/user/")) - services = ["wthrc.service", "conky.service"] + services = ["wthrc.service", "conky.service", "conkyconf.service"] if serviceDirExist: delivered = filecmp.cmpfiles( os.path.join(projectDir, "services/"),