discord: added focus-window script to hyprland
This commit is contained in:
parent
688981cb16
commit
33580a8bff
|
@ -19,10 +19,9 @@ in
|
|||
timeout-low = 3;
|
||||
|
||||
scripts = {
|
||||
_99-play-notification-sound = {
|
||||
_98-play-notification-sound-normal = {
|
||||
exec = ''${pkgs.sox}/bin/play --volume 0.5 ${./gran_turismo_menu_sound_effect.mp3}'';
|
||||
app-name = "^(?!discord|TelegramDesktop|Slack|slack|Signal|Element).*$";
|
||||
urgency = "Normal";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib.meta) getExe;
|
||||
cfg = config.profile.discord;
|
||||
in
|
||||
{
|
||||
|
@ -18,5 +19,15 @@ in
|
|||
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"
|
||||
];
|
||||
|
||||
services.swaync.settings.scripts._10-discord =
|
||||
let
|
||||
script = pkgs.callPackage ../../scripts/hyprland/focus-window.nix { };
|
||||
in
|
||||
{
|
||||
app-name = "discord";
|
||||
exec = "${getExe script}";
|
||||
run-on = "action";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
14
scripts/hyprland/focus-window.nix
Normal file
14
scripts/hyprland/focus-window.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
|
||||
gojq = "${pkgs.gojq}/bin/gojq";
|
||||
in
|
||||
pkgs.writeShellScriptBin "focus-window.sh" /*sh*/ ''
|
||||
appname="$SWAYNC_APP_NAME"
|
||||
state="$(${hyprctl} -j clients)"
|
||||
window="$(echo "$state" | ${gojq} -r --arg APP "$appname" '.[] | select(.class == $APP) | .address')"
|
||||
|
||||
if [[ "$window" != "" ]]; then
|
||||
${hyprctl} dispatch focuswindow address:"$window"
|
||||
fi
|
||||
''
|
Loading…
Reference in a new issue