home/hyprland: move variables and rules into vars.nix

This commit is contained in:
Aly Raffauf 2024-07-07 01:36:41 -04:00
parent b27ec564a0
commit c8f162cf3b
3 changed files with 458 additions and 435 deletions

View file

@ -1,14 +1,27 @@
{
pkgs,
lib,
config,
inputs,
lib,
pkgs,
...
}: {
config = lib.mkIf config.ar.home.desktop.hyprland.enable {
config = let
cfg = config.ar.home;
in
lib.mkIf cfg.desktop.hyprland.enable {
wayland.windowManager.hyprland.enable = true;
wayland.windowManager.hyprland.extraConfig = let
modifier = "SUPER";
inherit
(import ./vars.nix)
defaultWorkspaces
externalMonitors
laptopMonitors
layerRules
modifier
windowManagerBinds
windowRules
;
# Hyprland desktop utilities
hyprnome = lib.getExe pkgs.hyprnome;
@ -16,24 +29,23 @@
# Default apps
defaultApps = {
browser = lib.getExe config.ar.home.defaultApps.webBrowser;
editor = lib.getExe config.ar.home.defaultApps.editor;
fileManager = lib.getExe config.ar.home.defaultApps.fileManager;
browser = lib.getExe cfg.defaultApps.webBrowser;
editor = lib.getExe cfg.defaultApps.editor;
fileManager = lib.getExe cfg.defaultApps.fileManager;
launcher = lib.getExe pkgs.fuzzel;
lock = lib.getExe pkgs.swaylock;
logout = lib.getExe pkgs.wlogout;
passwordManager = lib.getExe' pkgs.keepassxc "keepassxc";
terminal = lib.getExe config.ar.home.defaultApps.terminal;
terminal = lib.getExe cfg.defaultApps.terminal;
virtKeyboard = lib.getExe' pkgs.squeekboard "squeekboard";
};
wallpaperd =
if config.ar.home.desktop.hyprland.randomWallpaper
if cfg.desktop.hyprland.randomWallpaper
then
pkgs.writers.writeRuby "hyprland-randomWallpaper" {} ''
require 'fileutils'
directory = "${pkgs.alyraffauf-wallpapers}/share/backgrounds"
directory = "${inputs.wallpapers.packages.${pkgs.system}.default}/share/backgrounds"
hyprctl = "${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"}"
old_pids = []
@ -66,7 +78,7 @@
end
end
''
else "${lib.getExe pkgs.swaybg} -i ${config.ar.home.theme.wallpaper}";
else "${lib.getExe pkgs.swaybg} -i ${cfg.theme.wallpaper}";
startupApps =
[
@ -80,7 +92,7 @@
(lib.getExe pkgs.mako)
"${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1"
]
++ lib.lists.optional (config.ar.home.desktop.hyprland.redShift)
++ lib.lists.optional (cfg.desktop.hyprland.redShift)
"${lib.getExe pkgs.gammastep} -l 33.74:-84.38";
screenshot = rec {
@ -90,34 +102,6 @@
region = "${bin} -m region -o ${folder}";
};
windowManagerBinds = {
down = "d";
left = "l";
right = "r";
up = "u";
h = "l";
j = "d";
k = "u";
l = "r";
};
defaultWorkspaces = [1 2 3 4 5 6 7 8 9];
laptopMonitors = {
framework = "desc:BOE 0x095F,preferred,auto,1.6";
t440p = "desc:LG Display 0x0569,preferred,auto,1.0";
yoga9i = "desc:Samsung Display Corp. 0x4152,preferred,auto,2,transform,0";
};
externalMonitors = {
homeOffice0 = "desc:LG Electronics LG ULTRAWIDE 311NTAB5M720,preferred,auto,1.25,vrr,2";
homeOffice1 = "desc:LG Electronics LG IPS QHD 109NTWG4Y865,preferred,-2560x0,auto";
homeOffice3 = "desc:LG Electronics LG ULTRAWIDE 207NTHM9F673, preferred,auto,1.25,vrr,2";
homeOffice4 = "desc:LG Electronics LG IPS QHD 207NTVSE5615,preferred,-1152x0,1.25,transform,1";
workShop = "desc:Guangxi Century Innovation Display Electronics Co. Ltd 27C1U-D 0000000000001,preferred,-2400x0,1.6";
weWork = "desc:HP Inc. HP 24mh 3CM037248S,preferred,-1920x0,auto";
};
gdk_scale = "1.5";
clamshell = pkgs.writeShellScript "hyprland-clamshell" ''
@ -183,7 +167,7 @@
timeout 330 '${hyprctl} dispatch dpms off' \
resume '${hyprctl} dispatch dpms on' \
${
if config.ar.home.desktop.hyprland.autoSuspend
if cfg.desktop.hyprland.autoSuspend
then ''timeout 900 'sleep 2 && ${lib.getExe' pkgs.systemd "systemctl"} suspend' \''
else ''\''
}
@ -255,8 +239,8 @@
gaps_in = 5
gaps_out = 6
border_size = 2
col.active_border = rgba(${lib.strings.removePrefix "#" config.ar.home.theme.colors.secondary}EE) rgba(${lib.strings.removePrefix "#" config.ar.home.theme.colors.primary}EE) 45deg
col.inactive_border = rgba(${lib.strings.removePrefix "#" config.ar.home.theme.colors.inactive}AA)
col.active_border = rgba(${lib.strings.removePrefix "#" cfg.theme.colors.secondary}EE) rgba(${lib.strings.removePrefix "#" cfg.theme.colors.primary}EE) 45deg
col.inactive_border = rgba(${lib.strings.removePrefix "#" cfg.theme.colors.inactive}AA)
layout = dwindle
@ -273,19 +257,12 @@
drop_shadow = yes
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(${lib.strings.removePrefix "#" config.ar.home.theme.colors.shadow}EE)
col.shadow = rgba(${lib.strings.removePrefix "#" cfg.theme.colors.shadow}EE)
dim_special = 0.5
# Window-specific rules
layerrule = blur, waybar
layerrule = ignorezero, waybar
layerrule = blur, launcher
layerrule = blur, notifications
layerrule = ignorezero, notifications
layerrule = blur, logout_dialog
layerrule = blur, swayosd
layerrule = ignorezero, swayosd
${layerRules}
}
animations {
@ -318,36 +295,12 @@
}
# Window Rules
${
lib.strings.concatMapStringsSep "\n"
(x: ''
windowrulev2 = center(1),class:(${x})
windowrulev2 = float,class:(${x})
windowrulev2 = size 40% 60%,class:(${x}})
'')
[
".blueman-manager-wrapped"
"blueberry.py"
"com.github.wwmm.easyeffects"
"pavucontrol"
]
}
windowrulev2 = center(1),class:(org.keepassxc.KeePassXC)
windowrulev2 = float,class:(org.keepassxc.KeePassXC)
windowrulev2 = size 80% 80%,class:(org.keepassxc.KeePassXC)
windowrulev2 = float, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = move 70% 20%, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = pin, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = suppressevent maximize, class:.*
${windowRules}
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = ${modifier}, B, exec, ${defaultApps.browser}
bind = ${modifier}, E, exec, ${defaultApps.editor}
bind = ${modifier}, F, exec, ${defaultApps.fileManager}
bind = ${modifier}, P, exec, ${defaultApps.passwordManager}
bind = ${modifier}, R, exec, ${defaultApps.launcher}
bind = ${modifier}, T, exec, ${defaultApps.terminal}

View file

@ -0,0 +1,63 @@
{
defaultWorkspaces = [1 2 3 4 5 6 7 8 9];
externalMonitors = {
homeOffice0 = "desc:LG Electronics LG ULTRAWIDE 311NTAB5M720,preferred,auto,1.25,vrr,2";
homeOffice1 = "desc:LG Electronics LG IPS QHD 109NTWG4Y865,preferred,-2560x0,auto";
homeOffice3 = "desc:LG Electronics LG ULTRAWIDE 207NTHM9F673, preferred,auto,1.25,vrr,2";
homeOffice4 = "desc:LG Electronics LG IPS QHD 207NTVSE5615,preferred,-1152x0,1.25,transform,1";
workShop = "desc:Guangxi Century Innovation Display Electronics Co. Ltd 27C1U-D 0000000000001,preferred,-2400x0,1.6";
weWork = "desc:HP Inc. HP 24mh 3CM037248S,preferred,-1920x0,auto";
};
laptopMonitors = {
framework = "desc:BOE 0x095F,preferred,auto,1.6";
t440p = "desc:LG Display 0x0569,preferred,auto,1.0";
yoga9i = "desc:Samsung Display Corp. 0x4152,preferred,auto,2,transform,0";
};
layerRules = ''
# Window-specific rules
layerrule = blur, waybar
layerrule = ignorezero, waybar
layerrule = blur, launcher
layerrule = blur, notifications
layerrule = ignorezero, notifications
layerrule = blur, logout_dialog
layerrule = blur, swayosd
layerrule = ignorezero, swayosd
'';
modifier = "SUPER";
windowManagerBinds = {
down = "d";
left = "l";
right = "r";
up = "u";
h = "l";
j = "d";
k = "u";
l = "r";
};
windowRules = ''
windowrulev2 = center(1),class:(.blueman-manager-wrapped)
windowrulev2 = float,class:(.blueman-manager-wrapped)
windowrulev2 = size 40% 60%,class:(.blueman-manager-wrapped})
windowrulev2 = center(1),class:(com.github.wwmm.easyeffects)
windowrulev2 = float,class:(com.github.wwmm.easyeffects)
windowrulev2 = size 40% 60%,class:(com.github.wwmm.easyeffects})
windowrulev2 = center(1),class:(pavucontrol)
windowrulev2 = float,class:(pavucontrol)
windowrulev2 = size 40% 60%,class:(pavucontrol})
windowrulev2 = float, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = move 70% 20%, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = pin, class:^(firefox)$, title:^(Picture-in-Picture)$
windowrulev2 = suppressevent maximize, class:.*
'';
}

View file

@ -48,6 +48,13 @@
};
};
wayland.windowManager.hyprland.extraConfig = ''
bind = SUPER, P, exec, ${lib.getExe' pkgs.keepassxc "keepassxc"}
windowrulev2 = center(1),class:(org.keepassxc.KeePassXC)
windowrulev2 = float,class:(org.keepassxc.KeePassXC)
windowrulev2 = size 80% 80%,class:(org.keepassxc.KeePassXC)
'';
ar.home = {
apps = {
alacritty.enable = true;