From d8037819f01ef2eb920516ce50237a922019684b Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:40:17 +1000 Subject: ci: add flake update workflow Also add contributing, funding and issue templates parser: add kill option to shell version: fix errors when not on arch --- src/caelestia/parser.py | 1 + src/caelestia/subcommands/shell.py | 3 +++ src/caelestia/utils/version.py | 54 +++++++++++++++++++++++--------------- 3 files changed, 37 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/caelestia/parser.py b/src/caelestia/parser.py index 550842d..35266b2 100644 --- a/src/caelestia/parser.py +++ b/src/caelestia/parser.py @@ -22,6 +22,7 @@ def parse_args() -> (argparse.ArgumentParser, argparse.Namespace): shell_parser.add_argument("-d", "--daemon", action="store_true", help="start the shell detached") shell_parser.add_argument("-s", "--show", action="store_true", help="print all shell IPC commands") shell_parser.add_argument("-l", "--log", action="store_true", help="print the shell log") + shell_parser.add_argument("-k", "--kill", action="store_true", help="kill the shell") shell_parser.add_argument("--log-rules", metavar="RULES", help="log rules to apply") # Create parser for toggle opts diff --git a/src/caelestia/subcommands/shell.py b/src/caelestia/subcommands/shell.py index 06f3b45..4cdd128 100644 --- a/src/caelestia/subcommands/shell.py +++ b/src/caelestia/subcommands/shell.py @@ -17,6 +17,9 @@ class Command: elif self.args.log: # Print the log self.print_log() + elif self.args.kill: + # Kill the shell + self.shell("kill") elif self.args.message: # Send a message self.message(*self.args.message) diff --git a/src/caelestia/utils/version.py b/src/caelestia/utils/version.py index 7c5ce88..5e75387 100644 --- a/src/caelestia/utils/version.py +++ b/src/caelestia/utils/version.py @@ -1,30 +1,42 @@ +import shutil import subprocess from caelestia.utils.paths import config_dir def print_version() -> None: - print("Packages:") - pkgs = ["caelestia-shell-git", "caelestia-cli-git", "caelestia-meta"] - versions = subprocess.run( - ["pacman", "-Q", *pkgs], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True - ).stdout - - for pkg in pkgs: - if pkg not in versions: - print(f" {pkg} not installed") - print("\n".join(f" {pkg}" for pkg in versions.splitlines())) - - caelestia_dir = (config_dir / "hypr").resolve().parent - print("\nCaelestia:") - caelestia_ver = subprocess.check_output( - ["git", "--git-dir", caelestia_dir / ".git", "rev-list", "--format=%B", "--max-count=1", "HEAD"], text=True - ) - print(" Last commit:", caelestia_ver.split()[1]) - print(" Commit message:", *caelestia_ver.splitlines()[1:]) - - print("\nQuickshell:") - print(" ", subprocess.check_output(["qs", "--version"], text=True).strip()) + if shutil.which("pacman"): + print("Packages:") + pkgs = ["caelestia-shell-git", "caelestia-cli-git", "caelestia-meta"] + versions = subprocess.run( + ["pacman", "-Q", *pkgs], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True + ).stdout + + for pkg in pkgs: + if pkg not in versions: + print(f" {pkg} not installed") + print("\n".join(f" {pkg}" for pkg in versions.splitlines())) + else: + print("Packages: not on Arch") + + print() + try: + caelestia_dir = (config_dir / "hypr").resolve().parent + caelestia_ver = subprocess.check_output( + ["git", "--git-dir", caelestia_dir / ".git", "rev-list", "--format=%B", "--max-count=1", "HEAD"], text=True + ) + print("Caelestia:") + print(" Last commit:", caelestia_ver.split()[1]) + print(" Commit message:", *caelestia_ver.splitlines()[1:]) + except subprocess.CalledProcessError: + print("Caelestia: not installed") + + print() + if shutil.which("qs"): + print("Quickshell:") + print(" ", subprocess.check_output(["qs", "--version"], text=True).strip()) + else: + print("Quickshell: not in PATH") local_shell_dir = config_dir / "quickshell/caelestia" if local_shell_dir.exists(): -- cgit v1.2.3-freya