slack: moved autostart script in hyprland

This commit is contained in:
Tigor Hutasuhut 2024-10-20 13:05:15 +07:00
parent 3490576ddb
commit 12199d0b2f
4 changed files with 14 additions and 51 deletions

View file

@ -201,9 +201,6 @@ in
exec-once=pasystray exec-once=pasystray
source=${config.home.homeDirectory}/.cache/wallust/hyprland.conf source=${config.home.homeDirectory}/.cache/wallust/hyprland.conf
exec-once=bash -c "sleep 10; until ping -c 1 google.com; do sleep 1; done; slack"
exec-once=bash -c "sleep 10; until ping -c 1 nextcloud.tigor.web.id; do sleep 1; done; nextcloud --background"
''; '';
}; };
}; };

View file

@ -1,56 +1,19 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
let let
cfg = config.profile.slack; cfg = config.profile.slack;
script = 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;
in in
{ {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = with pkgs; [ slack ]; home.packages = with pkgs; [ slack ];
systemd.user = lib.mkIf cfg.autostart { wayland.windowManager.hyprland.settings.exec-once = lib.mkIf cfg.autostart [
# Unlike Discord, Slack is only used on office hours, scriptFile
# so we will use a timer to start it on office hours only. ];
timers.slack = {
Unit = { home.file.".config/autostart/slack.sh".source = lib.mkIf cfg.autostart scriptFile;
Description = "Start Slack Desktop Client on Weekdays on Login";
};
Timer = {
OnCalendar = "Mon..Fri 09..18:*:*";
};
Install = {
WantedBy = [ "timers.target" ];
};
};
services.slack = {
Unit = {
Description = "Slack Desktop Client";
Wants = [ "graphical.target" ];
StartLimitIntervalSec = 300;
StartLimitBurst = 10;
};
Service =
let
bash = "${pkgs.bash}/bin/bash";
ping = "${pkgs.unixtools.ping}/bin/ping";
host = "google.com"; # slack.com does not respond to ping
sleep = "${pkgs.coreutils}/bin/sleep";
slack = "${pkgs.slack}/bin/slack";
exec = ''${bash} -c "until ${ping} -c 1 ${host}; do ${sleep} 1; done; ${slack}"'';
in
{
Type = "simple";
ExecStartPre = "${sleep} 5";
ExecStart = exec;
Restart = "on-failure";
# Prevent Slack from auto-restarting when user closes it.
# The timer setup above will trigger this service
# if RemaiAfterExit is not set to "yes".
#
# This will mark the service as still "Active" by systemd
# hence the timer will not trigger the service again.
RemainAfterExit = "yes";
Environment = [ "NIXOS_OZONE_WL=1" ];
};
};
};
}; };
} }

View file

@ -86,7 +86,7 @@ in
/*bash*/ /*bash*/
'' ''
packfiles() { packfiles() {
find $(nix build "nixpkgs#$1" --no-link --print-out-paths) find $(NIXPKGS_ALLOW_UNFREE=1 nix build "nixpkgs#$1" --impure --no-link --print-out-paths)
} }
build() { build() {

View file

@ -52,7 +52,10 @@ in
enable = true; enable = true;
autostart = true; autostart = true;
}; };
slack.enable = true; slack = {
enable = true;
autostart = true;
};
whatsapp = { whatsapp = {
enable = true; enable = true;
autostart = true; autostart = true;