From 9b5b84ed5afe4b523c846984354705f1b6186c26 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Mon, 21 Oct 2024 10:05:12 +0700 Subject: [PATCH] slack, discord: autostart on fort profile --- home/programs/discord.nix | 24 +++++++++++++++++------- home/programs/slack.nix | 21 +++++++++++++++++---- profiles/fort.nix | 10 ++++++++-- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/home/programs/discord.nix b/home/programs/discord.nix index f897272..e9b2719 100644 --- a/home/programs/discord.nix +++ b/home/programs/discord.nix @@ -3,6 +3,14 @@ let inherit (lib) mkIf; inherit (lib.meta) getExe; cfg = config.profile.discord; + autostartScript = pkgs.writeShellScriptBin "discord.sh" /*sh*/ '' + sleep 10; + until ${pkgs.unixtools.ping}/bin/ping -c 1 discord.com; + do sleep 1; + done; + vesktop + ''; + autostartScriptFile = getExe autostartScript; in { config = mkIf cfg.enable { @@ -10,23 +18,25 @@ in vesktop ]; - home.file = { - ".config/discord/settings.json".text = builtins.toJSON { - SKIP_HOST_UPDATE = true; - }; + home.file.".config/discord/settings.json".text = builtins.toJSON { + SKIP_HOST_UPDATE = true; }; wayland.windowManager.hyprland.settings.exec-once = lib.mkIf cfg.autostart [ - "sleep 10; until ${pkgs.unixtools.ping}/bin/ping -c 1 discord.com; do sleep 1; done; vesktop" + autostartScriptFile ]; + home.file.".config/autostart/discord.sh" = lib.mkIf cfg.autostart { + source = autostartScriptFile; + }; + services.swaync.settings.scripts._10-discord = let - script = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { }; + focusWindowScript = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { }; in { app-name = "(?=discord|vesktop)"; - exec = "${getExe script}"; + exec = "${getExe focusWindowScript}"; run-on = "action"; }; }; diff --git a/home/programs/slack.nix b/home/programs/slack.nix index 3b815ea..604e2fa 100644 --- a/home/programs/slack.nix +++ b/home/programs/slack.nix @@ -1,19 +1,32 @@ { pkgs, lib, config, ... }: let cfg = config.profile.slack; - script = pkgs.writeShellScriptBin "slack.sh" '' + autostartScript = pkgs.writeShellScriptBin "slack.sh" '' sleep 10; until ${pkgs.unixtools.ping}/bin/ping -c 1 1.1.1.1; do sleep 1; done; slack ''; - scriptFile = lib.meta.getExe script; + inherit (lib.meta) getExe; + autostartScriptFile = getExe autostartScript; in { config = lib.mkIf cfg.enable { home.packages = with pkgs; [ slack ]; wayland.windowManager.hyprland.settings.exec-once = lib.mkIf cfg.autostart [ - scriptFile + autostartScriptFile ]; - home.file.".config/autostart/slack.sh".source = lib.mkIf cfg.autostart scriptFile; + home.file.".config/autostart/slack.sh" = lib.mkIf cfg.autostart { + source = autostartScriptFile; + }; + + services.swaync.settings.scripts._10-slack = + let + focusWindowScript = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { }; + in + { + app-name = "[Ss]lack"; + exec = "${getExe focusWindowScript}"; + run-on = "action"; + }; }; } diff --git a/profiles/fort.nix b/profiles/fort.nix index 5a70cb9..4b48cea 100644 --- a/profiles/fort.nix +++ b/profiles/fort.nix @@ -37,8 +37,14 @@ pyprland.wallpaper-dirs = [ "/home/tigor/Syncthing/Redmage/Laptop-Kerja" ]; wallust.alpha = 80; }; - discord.enable = true; - slack.enable = true; + discord = { + enable = true; + autostart = true; + }; + slack = { + enable = true; + autostart = true; + }; whatsapp.enable = true; syncthing.enable = true; bluetooth.enable = true;