swaync: simplified focus window scripts

This commit is contained in:
Tigor Hutasuhut 2024-10-21 23:17:24 +07:00
parent f88c2e1fe1
commit ef13bf83c8
6 changed files with 22 additions and 50 deletions

View file

@ -24,6 +24,11 @@ in
timeout-low = 3; timeout-low = 3;
scripts = { scripts = {
_10-hyprland-ytptube = {
app-name = "ytptube";
exec = ''hyprctl dispatch exec "xdg-open https://ytptube.tigor.web.id"'';
run-on = "action";
};
_98-play-notification-sound-normal = { _98-play-notification-sound-normal = {
exec = ''${pkgs.sox}/bin/play --volume 0.5 ${./gran_turismo_menu_sound_effect.mp3}''; exec = ''${pkgs.sox}/bin/play --volume 0.5 ${./gran_turismo_menu_sound_effect.mp3}'';
app-name = "^(?!discord|TelegramDesktop|Slack|slack|Signal|Element|whatsapp-for-linux).*$"; app-name = "^(?!discord|TelegramDesktop|Slack|slack|Signal|Element|whatsapp-for-linux).*$";
@ -32,27 +37,6 @@ in
}; };
}; };
systemd.user.services.swaync = {
Unit = {
X-Reload-Triggers = [
(pkgs.writeText "swaync/config.json" (builtins.toJSON config.services.swaync.settings))
config.services.swaync.style
];
};
Service =
let
reloadScript =
pkgs.writeShellScriptBin "swaync-reload.sh" # sh
''
${pkgs.swaynotificationcenter}/bin/swaync-client --reload-config
${pkgs.swaynotificationcenter}/bin/swaync-client --reload-css
'';
in
{
ExecReload = "${lib.meta.getExe reloadScript}";
};
};
home.packages = with pkgs; [ libnotify ]; home.packages = with pkgs; [ libnotify ];
}; };
} }

View file

@ -67,7 +67,7 @@ in
alpha = 100; alpha = 100;
threshold = 1; threshold = 1;
palette = "dark"; palette = "dark";
checkContrast = true; check_contrast = true;
} }
cfg.wallust.settings cfg.wallust.settings
] ]

View file

@ -29,14 +29,10 @@ in
home.file.".config/autostart/discord.sh" = lib.mkIf cfg.autostart { source = autostartScriptFile; }; home.file.".config/autostart/discord.sh" = lib.mkIf cfg.autostart { source = autostartScriptFile; };
services.swaync.settings.scripts._10-discord = services.swaync.settings.scripts._10-discord = {
let app-name = "(?=discord|vesktop)";
focusWindowScript = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { }; exec = "hyprctl dispatch focuswindow $SWAYNC_APP_NAME";
in run-on = "action";
{ };
app-name = "(?=discord|vesktop)";
exec = "${getExe focusWindowScript}";
run-on = "action";
};
}; };
} }

View file

@ -20,14 +20,10 @@ in
home.file.".config/autostart/slack.sh" = lib.mkIf cfg.autostart { source = autostartScriptFile; }; home.file.".config/autostart/slack.sh" = lib.mkIf cfg.autostart { source = autostartScriptFile; };
services.swaync.settings.scripts._10-slack = services.swaync.settings.scripts._10-slack = {
let app-name = "[Ss]lack";
focusWindowScript = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { }; exec = "hyprctl dispatch focuswindow $SWAYNC_APP_NAME";
in run-on = "action";
{ };
app-name = "[Ss]lack";
exec = "${getExe focusWindowScript}";
run-on = "action";
};
}; };
} }

View file

@ -22,14 +22,10 @@ in
source = "${lib.meta.getExe autostartScript}"; source = "${lib.meta.getExe autostartScript}";
}; };
services.swaync.settings.scripts._10-whatsapp = services.swaync.settings.scripts._10-whatsapp = {
let app-name = "whatsapp-for-linux";
focusWindowScript = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { }; exec = "hyprctl dispatch focuswindow whatsapp-for-linux";
in run-on = "action";
{ };
app-name = "whatsapp-for-linux";
exec = "${lib.meta.getExe focusWindowScript}";
run-on = "action";
};
}; };
} }

View file

@ -184,7 +184,7 @@ lib.mkMerge [
in in
[ [
{ {
command = ''${pkgs.libnotify}/bin/notify-send --app-name="YTPTUBE" --icon="${vueIcon}" --category=im.received --urgency=normal "$title" "$message"''; command = ''${pkgs.libnotify}/bin/notify-send --app-name="ytptube" --icon="${vueIcon}" --category=im.received --urgency=normal "$title" "$message"'';
topic = "ytptube"; topic = "ytptube";
} }
]; ];