From 8706085d15b4ecb0eeaa85bc8e779a4e36c52eb8 Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Sat, 1 Mar 2025 10:21:17 +0100 Subject: [PATCH] Switch to hyprpaper --- modules/hm/hyprland.nix | 21 +++++++++++---- pkgs/wl-update-background/default.nix | 37 ++++++++++++++++++--------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/modules/hm/hyprland.nix b/modules/hm/hyprland.nix index 7b56cb8..b87bef2 100644 --- a/modules/hm/hyprland.nix +++ b/modules/hm/hyprland.nix @@ -43,13 +43,23 @@ in ; }; - services.network-manager-applet.enable = true; - services.blueman-applet.enable = true; + services = { + network-manager-applet.enable = true; + blueman-applet.enable = true; - systemd.user.services.blueman-applet = { - Service = { Restart = "on-failure"; RestartSec = "3s"; }; + hyprpaper = { + enable = true; + settings = { + preload = "${../../wallpapers/n8ca4obsys991.png}"; + wallpaper = [ ",${../../wallpapers/n8ca4obsys991.png}" ]; + }; + }; }; + systemd.user.services = { + blueman-applet.Service = { Restart = "on-failure"; RestartSec = "3s"; }; + network-manager-applet.Service = { Restart = "on-failure"; RestartSec = "3s"; }; + }; wayland.windowManager.hyprland = { enable = true; @@ -72,7 +82,8 @@ in "noti -t 'Hyprland' -m 'New config loaded\!'" ]; exec-once = [ - "swww init" + # "swww init" + "${pkgs.hyprpaper}/bin/hyprpaper" ]; # exec-shutdown = [ ]; diff --git a/pkgs/wl-update-background/default.nix b/pkgs/wl-update-background/default.nix index 951f501..5dc1470 100644 --- a/pkgs/wl-update-background/default.nix +++ b/pkgs/wl-update-background/default.nix @@ -1,16 +1,29 @@ { findutils -, gnugrep , coreutils , writeShellScriptBin -, swww +, hyprland , backgrounds_directory ? "$HOME/Immagini/Sfondi/" -}: writeShellScriptBin "wl-update-background" '' - set -e - if [ $# -eq 0 ]; then - image=`${findutils}/bin/find ${backgrounds_directory} -type f | ${gnugrep}/bin/grep -v "/\." | ${coreutils}/bin/shuf -n 1` - else - image="$1" - fi - echo "image: $image" - ${swww}/bin/swww img "$image" -'' +}: writeShellScriptBin "wl-update-background" + + # '' + # set -e + # if [ $# -eq 0 ]; then + # image=`${findutils}/bin/find ${backgrounds_directory} -type f | ${gnugrep}/bin/grep -v "/\." | ${coreutils}/bin/shuf -n 1` + # else + # image="$1" + # fi + # echo "image: $image" + # ${swww}/bin/swww img "$image" + # '' + + '' + set -euo pipefail + WALLPAPER_DIR=${backgrounds_directory} + CURRENT_WALL=$(hyprctl hyprpaper listloaded) + + # Get a random wallpaper that is not the current one + WALLPAPER=$(${findutils}/bin/find "$WALLPAPER_DIR" -type f ! -name "$(${coreutils}/bin/basename "$CURRENT_WALL")" | ${coreutils}/bin/shuf -n 1) + + # Apply the selected wallpaper + ${hyprland}/bin/hyprctl hyprpaper reload ,"$WALLPAPER" + ''