From e778ef13c778bea7bccf24e7fe09d06d96b8d8b0 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Mon, 21 Oct 2024 21:38:07 +0700 Subject: [PATCH] whatsapp: add autostart script and focus window script --- home/programs/whatsapp.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/home/programs/whatsapp.nix b/home/programs/whatsapp.nix index 57d5822..9a61e1d 100644 --- a/home/programs/whatsapp.nix +++ b/home/programs/whatsapp.nix @@ -6,13 +6,30 @@ }: let cfg = config.profile.whatsapp; + autostartScript = pkgs.writeShellScriptBin "whatsapp.sh" '' + "sleep 10; until ${pkgs.unixtools.ping}/bin/ping -c 1 web.whatsapp.com; do sleep 1; done; whatsapp-for-linux" + ''; in { config = lib.mkIf cfg.enable { home.packages = [ pkgs.whatsapp-for-linux ]; wayland.windowManager.hyprland.settings.exec-once = lib.mkIf cfg.autostart [ - "sleep 10; until ${pkgs.unixtools.ping}/bin/ping -c 1 web.whatsapp.com; do sleep 1; done; whatsapp-for-linux" + "${lib.meta.getExe autostartScript}" ]; + + home.file.".config/autostart/whatsapp.sh" = lib.mkIf cfg.autostart { + source = "${lib.meta.getExe autostartScript}"; + }; + + services.swaync.settings.scripts._10-whatsapp = + let + focusWindowScript = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { }; + in + { + app-name = "whatsapp-for-linux"; + exec = "${lib.meta.getExe focusWindowScript}"; + run-on = "action"; + }; }; }