#!/usr/bin/env python3 # docstring=wraps kanshictl and adds features from os import environ import os.path as path import subprocess as sp import sys SCRIPT_FILENAME = path.basename(__file__) HOME = environ["HOME"] CFG = { "config_path": path.join(HOME, ".config/kanshi/config"), "kanshi_bin": "kanshictl" } def kctl(*args): args = list(args) completed = sp.run([CFG["kanshi_bin"]] + args, capture_output=True, text=True) stderr = completed.stderr if "Usage: kanshictl" in stderr: print(stderr) print(f"Wrapped options form {SCRIPT_FILENAME}:") print(" list list all available profiles") sys.exit(completed.returncode) def list_profiles(config_path=CFG["config_path"]): with open(config_path, "r") as file_fd: for line in file_fd: line = line.strip(" ").strip("\n") if line.startswith("profile"): print(line.split()[1]) def main(): arguments = sys.argv[1:] match arguments[0]: case "list": list_profiles() case _: kctl(*arguments) if __name__ == "__main__": main()