From e9c95ee2e9e7409bf9dc2a759ef24ec955f2e2aa Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Tue, 5 Mar 2024 03:47:40 +0530 Subject: [PATCH] [feat] Add hyprpaper --- config/nix/common/home.nix | 3 +- config/nix/linux/hyprland.nix | 26 +++++++- config/nix/modules/hyprpaper.nix | 98 ++++++++++++++++++++++++++++++ config/nix/nixos/configuration.nix | 1 + 4 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 config/nix/modules/hyprpaper.nix diff --git a/config/nix/common/home.nix b/config/nix/common/home.nix index 2427b1bc..cb082a04 100644 --- a/config/nix/common/home.nix +++ b/config/nix/common/home.nix @@ -47,12 +47,13 @@ in (nerdfonts.override { fonts = [ "Hasklig" ]; }) mpv ] ++ (if device.isLinux then [ + gnome.seahorse gnome.nautilus nextcloud-client sbctl gparted gptfdisk - polkit-kde-agent + polkit_gnome dig mullvad steam-run diff --git a/config/nix/linux/hyprland.nix b/config/nix/linux/hyprland.nix index 02cb8625..d3122a14 100644 --- a/config/nix/linux/hyprland.nix +++ b/config/nix/linux/hyprland.nix @@ -1,4 +1,23 @@ { pkgs, ... }: { + imports = [ ../modules/hyprpaper.nix ]; + programs.hyprpaper = + let + wallpapers = [ + (builtins.fetchurl + { + url = "https://w.wallhaven.cc/full/zy/wallhaven-zy2x7v.png"; + sha256 = + "1vy4knw8cdwb5gszgvjahnwa2g0hh5lmz3v2hbx1nylmjg2rzpda"; + }) + ]; + in + { + enable = true; + systemd.enable = true; + systemd.target = "hyprland-session.target"; + settings.preload = wallpapers; + settings.wallpapers = (map (wallpaper: "DP-1," + wallpaper) wallpapers); + }; wayland.windowManager.hyprland = { enable = true; @@ -32,8 +51,8 @@ gaps_in = 5; gaps_out = 20; border_size = 2; - "col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg"; - "col.inactive_border" = "rgba(595959aa)"; + "col.active_border" = "$mauve $mauve 45deg"; + "col.inactive_border" = "$crust"; }; decoration = { @@ -111,7 +130,8 @@ "QT_QPA_PLATFORM,wayland" ]; exec-once = [ - "${pkgs.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1" + # "${pkgs.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1" + "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1" # "${pkgs.swayosd}/bin/swayosd-server" # "${pkgs.swww}/bin/swww init; swww img ~/.local/share/dotfiles/images/wallpaper.jpg" "${pkgs.ironbar}/bin/ironbar" diff --git a/config/nix/modules/hyprpaper.nix b/config/nix/modules/hyprpaper.nix new file mode 100644 index 00000000..10e12475 --- /dev/null +++ b/config/nix/modules/hyprpaper.nix @@ -0,0 +1,98 @@ +{ pkgs, config, lib, ... }: + +with lib; + +let + cfg = config.programs.hyprpaper; +in +{ + options = { + programs.hyprpaper = { + enable = mkEnableOption "Hyprpaper - Wayland wallpaper utility"; + + systemd = { + enable = mkEnableOption "autostart service for Hyprpaper"; + + target = mkOption { + type = types.str; + default = "graphical-session.target"; + example = "hyprland-session.target"; + description = '' + The systemd target that will automatically start the Hyprpaper service. + ''; + }; + }; + + settings = with types; { + preload = mkOption { + type = listOf path; + default = [ ]; + description = '' + Wallpaper images that should be preloaded into memory + ''; + example = [ ./wallpapers/tensura.png ]; + }; + + wallpapers = mkOption { + type = listOf str; + default = [ ]; + description = '' + Wallpaper to monitor mapper + ''; + }; + + extraConfig = mkOption { + type = str; + default = ""; + description = "Check https://github.com/hyprwm/hyprpaper#usage for info"; + example = '' + newConfigOption = foo,bar + ''; + }; + }; + }; + }; + + config = { + home.packages = mkIf cfg.enable [ + pkgs.hyprpaper + ]; + + systemd.user.services.hyprpaper = mkIf cfg.systemd.enable { + Unit = { + Description = "autostart service for Hyprpaper"; + Documentation = "https://github.com/hyprwm/hyprpaper"; + BindsTo = [ "graphical-session.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + + Service = { + ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper"; + ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR2 $MAINPID"; + Restart = "on-failure"; + KillMode = "mixed"; + }; + + Install = { + WantedBy = [ + cfg.systemd.target + ]; + }; + }; + + xdg.configFile = mkIf cfg.enable { + "hypr/hyprpaper.conf".text = '' + # Auto-generated by Nix home-manager module + + # hyprpaper.settings.preload + ${(lists.foldl (acc: v: acc + "preload = ${v}\n") "" cfg.settings.preload)} + + # hyprpaper.settings.wallpapers + ${(lists.foldl (acc: v: acc + "wallpaper = ${v}\n") "" cfg.settings.wallpapers)} + + # hyprpaper.settings.extraConfig + ${cfg.settings.extraConfig} + ''; + }; + }; +} diff --git a/config/nix/nixos/configuration.nix b/config/nix/nixos/configuration.nix index 7b1d6832..ad0eb355 100644 --- a/config/nix/nixos/configuration.nix +++ b/config/nix/nixos/configuration.nix @@ -16,6 +16,7 @@ services.devmon.enable = true; services.gvfs.enable = true; services.udisks2.enable = true; + services.gnome.gnome-keyring.enable = true; nix.settings.auto-optimise-store = true; nix.gc.automatic = true;