From f6b56dae28c0138e74aab20b9a801c15197c4c0a Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Sun, 14 Apr 2024 14:45:49 +0200 Subject: [PATCH] Modularise the hyprland config --- modules/home/de/default.nix | 2 +- .../de/{hyprland.nix => hyprland/default.nix} | 76 +------------------ modules/home/de/hyprland/hypridlelock.nix | 45 +++++++++++ modules/home/de/hyprland/waybar.nix | 48 ++++++++++++ 4 files changed, 96 insertions(+), 75 deletions(-) rename modules/home/de/{hyprland.nix => hyprland/default.nix} (71%) create mode 100644 modules/home/de/hyprland/hypridlelock.nix create mode 100644 modules/home/de/hyprland/waybar.nix diff --git a/modules/home/de/default.nix b/modules/home/de/default.nix index 02d4892..f55693a 100644 --- a/modules/home/de/default.nix +++ b/modules/home/de/default.nix @@ -8,7 +8,7 @@ in { imports = [ ./qtile.nix - ./hyprland.nix + ./hyprland ]; options.myConfig.de = { diff --git a/modules/home/de/hyprland.nix b/modules/home/de/hyprland/default.nix similarity index 71% rename from modules/home/de/hyprland.nix rename to modules/home/de/hyprland/default.nix index cccace6..9b80fd5 100644 --- a/modules/home/de/hyprland.nix +++ b/modules/home/de/hyprland/default.nix @@ -1,5 +1,4 @@ { - inputs, config, pkgs, lib, @@ -8,8 +7,8 @@ cfg = config.myConfig.de; in { imports = [ - inputs.hyprlock.homeManagerModules.hyprlock - inputs.hypridle.homeManagerModules.hypridle + ./waybar.nix + ./hypridlelock.nix ]; options.myConfig.de.hyprland.enable = lib.mkEnableOption ""; @@ -22,77 +21,6 @@ in { splash=false ''; - programs.hyprlock = { - enable = true; - backgrounds = [ - { - path = "screenshot"; - blur_passes = 1; - blur_size = 6; - } - ]; - }; - - services.hypridle = let - hyprlockExe = "${lib.getExe inputs.hyprlock.packages.${pkgs.system}.default}"; - in { - enable = true; - lockCmd = "pidof ${hyprlockExe} || ${hyprlockExe}"; - # beforeSleepCmd = "loginctl lock-session"; - afterSleepCmd = "hyprctl dispatch dpms on"; - listeners = [ - { - timeout = 600; - onTimeout = "hyprctl dispatch dpms off"; - onResume = "hyprctl dispatch dpms on"; - } - { - timeout = 1200; - onTimeout = "loginctl lock-session"; - } - ]; - }; - - programs.waybar = { - enable = true; - systemd.enable = true; - - settings = { - mainBar = { - layer = "top"; - position = "top"; - spacing = 3; - - modules-left = ["clock"]; - modules-center = ["hyprland/workspaces"]; - modules-right = ["tray" "wireplumber" "backlight" "battery"]; - - "hyprland/workspaces" = { - active-only = false; - all-outputs = true; - }; - - backlight = { - device = "amdgpu_bl1"; - }; - }; - }; - - style = '' - * { - border: none; - border-radius: 0px; - font-family: "JetBrainsMono Nerd Font"; - font-size: 14px; - } - - window#waybar { - background-color: rgba(43, 48, 59, 0.5); - color: #ffffff; - } - ''; - }; - myConfig.rofi.enable = true; services.cliphist.enable = true; diff --git a/modules/home/de/hyprland/hypridlelock.nix b/modules/home/de/hyprland/hypridlelock.nix new file mode 100644 index 0000000..dff0d55 --- /dev/null +++ b/modules/home/de/hyprland/hypridlelock.nix @@ -0,0 +1,45 @@ +{ + inputs, + config, + pkgs, + lib, + ... +}: { + imports = [ + inputs.hyprlock.homeManagerModules.hyprlock + inputs.hypridle.homeManagerModules.hypridle + ]; + + config = lib.mkIf config.myConfig.de.hyprland.enable { + programs.hyprlock = { + enable = true; + backgrounds = [ + { + path = "screenshot"; + blur_passes = 1; + blur_size = 6; + } + ]; + }; + + services.hypridle = let + hyprlockExe = "${lib.getExe inputs.hyprlock.packages.${pkgs.system}.default}"; + in { + enable = true; + lockCmd = "pidof ${hyprlockExe} || ${hyprlockExe}"; + # beforeSleepCmd = "loginctl lock-session"; + afterSleepCmd = "hyprctl dispatch dpms on"; + listeners = [ + { + timeout = 600; + onTimeout = "hyprctl dispatch dpms off"; + onResume = "hyprctl dispatch dpms on"; + } + { + timeout = 1200; + onTimeout = "loginctl lock-session"; + } + ]; + }; + }; +} diff --git a/modules/home/de/hyprland/waybar.nix b/modules/home/de/hyprland/waybar.nix new file mode 100644 index 0000000..7cab8b3 --- /dev/null +++ b/modules/home/de/hyprland/waybar.nix @@ -0,0 +1,48 @@ +{ + config, + lib, + ... +}: { + config = lib.mkIf config.myConfig.de.hyprland.enable { + + programs.waybar = { + enable = true; + systemd.enable = true; + + settings = { + mainBar = { + layer = "top"; + position = "top"; + spacing = 3; + + modules-left = ["clock"]; + modules-center = ["hyprland/workspaces"]; + modules-right = ["tray" "wireplumber" "backlight" "battery"]; + + "hyprland/workspaces" = { + active-only = false; + all-outputs = true; + }; + + backlight = { + device = "amdgpu_bl1"; + }; + }; + }; + + style = '' + * { + border: none; + border-radius: 0px; + font-family: "JetBrainsMono Nerd Font"; + font-size: 14px; + } + + window#waybar { + background-color: rgba(43, 48, 59, 0.5); + color: #ffffff; + } + ''; + }; + }; +}