From 98a1a9e5b28117e4d9e3ad966ce6c2ca4d3102f5 Mon Sep 17 00:00:00 2001 From: Krzysztof Saczuk Date: Wed, 19 Jun 2024 08:35:07 +0200 Subject: [PATCH] refactor(hyprland): extract class/title names in window rules into variables --- modules/desktop/apps/_1password.nix | 21 +++++++++++---------- modules/desktop/apps/vesktop.nix | 5 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/desktop/apps/_1password.nix b/modules/desktop/apps/_1password.nix index 38800f0..c12b028 100644 --- a/modules/desktop/apps/_1password.nix +++ b/modules/desktop/apps/_1password.nix @@ -12,6 +12,7 @@ with lib.my; with lib.my.utils; let layout = findLayoutConfig config ({index, ...}: index == 1); # Main monitor monitor = getLayoutMonitor layout "wayland"; + class = "1Password"; in { programs = { _1password.enable = true; @@ -56,15 +57,15 @@ in { ]; windowrulev2 = [ - "float, class:(1Password)" - "center, class:(1Password)" - "monitor ${monitor}, class:(1Password)" - # "stayfocused,class:^(1Password)$" - "forceinput,class:^(1Password)$" - "windowdance,class:^(1Password)$" - "noblur,class:^(1Password)$" - "noinitialfocus,class:^(1Password)$" - "dimaround,class:^(1Password)$" + "float, class:(${class})" + "center, class:(${class})" + "monitor ${monitor}, class:(${class})" + # "stayfocused,class:^(${class})$" + "forceinput,class:^(${class})$" + "windowdance,class:^(${class})$" + "noblur,class:^(${class})$" + "noinitialfocus,class:^(${class})$" + "dimaround,class:^(${class})$" ]; }; @@ -73,7 +74,7 @@ in { bind = Ctrl Shift, P, submap, 1pass submap = 1pass - bind = Ctrl Shift, P, closewindow, class:^(1Password)$ + bind = Ctrl Shift, P, closewindow, class:^(${class})$ bind = Ctrl Shift, P, submap, reset submap = reset diff --git a/modules/desktop/apps/vesktop.nix b/modules/desktop/apps/vesktop.nix index 2a8aba4..2e125d3 100644 --- a/modules/desktop/apps/vesktop.nix +++ b/modules/desktop/apps/vesktop.nix @@ -12,6 +12,7 @@ with lib.my.utils; let vesktop = unstable.vesktop; layout = findLayoutConfig config ({index, ...}: index == 0); # Left monitor workspace = findLayoutWorkspace layout ({default, ...}: default); # Default workspace + class = "^(vesktop)$"; in { modules.desktop.wm.${desktop}.autostartPrograms = [ "${vesktop}/bin/vesktop" @@ -22,8 +23,8 @@ in { wayland.windowManager.hyprland.settings = mkIf (config.modules.desktop.wm.hyprland.enable) { windowrulev2 = [ - "workspace ${workspace.name}, class:^(vesktop)$" - "noinitialfocus, class:^(vesktop)$" + "workspace ${workspace.name}, class:${class}" + "noinitialfocus, class:${class}" ]; }; };