From 31d77f652aea23011a9301f0e7bf953070993824 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: Tue, 15 Oct 2024 18:16:19 +0300 Subject: [PATCH] add: conky config, edit service --- scripts/install.sh | 9 ++++++++- scripts/runner.sh | 4 ++++ services/conkyconf.service | 12 ++++++++++++ src/fix.py | 28 ++++++++++++++++++++++++++++ src/main.py | 4 ++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 services/conkyconf.service create mode 100644 src/fix.py diff --git a/scripts/install.sh b/scripts/install.sh index 87a0c65..d442041 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -3,9 +3,10 @@ SCRIPT=$(readlink -f "$0") DIR=$(dirname "$SCRIPT") -# Create dirrectory for systemd scripts +# Create dirrectory for systemd and conky scripts cd $HOME/.config/ mkdir -p systemd +mkdir -p conky cd systemd/ mkdir -p user @@ -13,8 +14,14 @@ mkdir -p user cd "$DIR" cp -ur ../services/* ~/.config/systemd/user +# Copy conky config +cp -ur ../configs/* ~/.config/conky + # Daemon launch /usr/bin/systemctl --user daemon-reload + /usr/bin/systemctl --user enable wthrc.service /usr/bin/systemctl --user enable conky.service +/usr/bin/systemctl --user enable conkyconf.service + echo "Done installer" \ No newline at end of file diff --git a/scripts/runner.sh b/scripts/runner.sh index e7d3826..75cf02a 100644 --- a/scripts/runner.sh +++ b/scripts/runner.sh @@ -3,4 +3,8 @@ # Launch daemon /usr/bin/systemctl --user restart wthrc.service /usr/bin/systemctl --user restart conky.service + +sleep 5 + +/usr/bin/systemctl --user restart conkyconf.service echo "Daemon started" \ No newline at end of file diff --git a/services/conkyconf.service b/services/conkyconf.service new file mode 100644 index 0000000..e8e0f13 --- /dev/null +++ b/services/conkyconf.service @@ -0,0 +1,12 @@ +[Unit] +Description=Service for conky configuration +After=conky.service + +[Service] +Type=oneshot +WorkingDirectory=/home/citrullux/ModernOSLabs/src +ExecStart=/usr/bin/python3 /home/citrullux/ModernOSLabs/src/main.py -f +Restart=always + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/src/fix.py b/src/fix.py new file mode 100644 index 0000000..f30ef9d --- /dev/null +++ b/src/fix.py @@ -0,0 +1,28 @@ +import os +from pathlib import Path +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: + 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: + 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: + lines = config.readlines() + if lines[44] != " own_window_type = 'desktop'," + "\n": + config_desktop(lines, homeDir) + sleep(5) + config_override(lines, homeDir) + else: + sleep(5) + config_override(lines, homeDir) diff --git a/src/main.py b/src/main.py index bab1d3d..1b5d012 100644 --- a/src/main.py +++ b/src/main.py @@ -1,12 +1,16 @@ from installer import install from server import weather_run +from fix import conky_fix import argparse flags = argparse.ArgumentParser() flags.add_argument("--install", "-i", action="store_true") +flags.add_argument("--fix", "-f", action="store_true") args = flags.parse_args() if args.install: install() +elif args.fix: + conky_fix() else: weather_run() \ No newline at end of file