From c632e4d9c392b97261abdeada7664216928191e6 Mon Sep 17 00:00:00 2001 From: "agausmann@fastmail.com" Date: Sat, 8 Feb 2025 09:34:39 -0600 Subject: [PATCH] Add waybar reload hook --- install.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/install.py b/install.py index 48b7af1..067841e 100755 --- a/install.py +++ b/install.py @@ -215,10 +215,11 @@ def main(): ) args = parser.parse_args() - raw_dir = args.dotfiles / "raw" - templates_dir = args.dotfiles / "templates" - include_dir = args.dotfiles / "include" - host_filename = args.dotfiles / "hosts" / "{}.toml".format(args.hostname) + dotfiles_dir: Path = args.dotfiles + raw_dir = dotfiles_dir / "raw" + templates_dir = dotfiles_dir / "templates" + include_dir = dotfiles_dir / "include" + host_filename = dotfiles_dir / "hosts" / "{}.toml".format(args.hostname) host_toml = { "name": args.hostname, @@ -277,6 +278,8 @@ def main(): ], ) + changed_paths = set() + for raw_path in raw_dir.glob("**/*"): if not raw_path.is_file(): continue @@ -287,6 +290,7 @@ def main(): print(rel_path) output_path.parent.mkdir(parents=True, exist_ok=True) shutil.copy(raw_path, output_path) + changed_paths.update(map(str, rel_path.parents)) for template_path in templates_dir.glob("**/*"): if not template_path.is_file(): @@ -312,6 +316,11 @@ def main(): # Copy permissions from original file output_path.chmod(template_path.stat().st_mode & 0o777) + changed_paths.update(map(str, rel_path.parents)) + + # Post-install hooks + if ".config/waybar" in changed_paths: + subprocess.call(["killall", "-USR2", "waybar"]) if __name__ == "__main__":