hyprland: migrate to swaybg

This commit is contained in:
Aly Raffauf 2024-05-26 01:25:13 -04:00
parent 20661e087e
commit 128bae8061
7 changed files with 59 additions and 74 deletions

View file

@ -46,7 +46,7 @@ in {
};
hyprland = {
enable = true;
hyprpaper.randomWallpaper = true;
randomWallpaper = true;
};
sway = {
enable = true;

View file

@ -27,7 +27,7 @@
defaultApps.enable = true;
hyprland = {
enable = true;
hyprpaper.randomWallpaper = false;
randomWallpaper = false;
};
sway = {
enable = true;

View file

@ -6,7 +6,7 @@
inputs,
...
}: {
imports = [./hypridle ./hyprlock ./hyprpaper ./hyprshade];
imports = [./hypridle ./hyprlock ./hyprshade ./randomWallpaper.nix];
options = {
alyraffauf.desktop.hyprland.enable =
@ -16,6 +16,11 @@
default = true;
type = lib.types.bool;
};
alyraffauf.desktop.hyprland.randomWallpaper = lib.mkOption {
description = "Whether to enable random wallpaper script.";
default = true;
type = lib.types.bool;
};
};
config = lib.mkIf config.alyraffauf.desktop.hyprland.enable {
@ -25,10 +30,7 @@
hyprland = {
hypridle.enable = lib.mkDefault false;
hyprlock.enable = lib.mkDefault false;
hyprpaper = {
enable = lib.mkDefault true;
randomWallpaper = lib.mkDefault true;
};
hyprshade.enable = lib.mkDefault true;
};
theme.enable = lib.mkDefault true;
@ -99,7 +101,7 @@
bar = lib.getExe pkgs.waybar;
launcher = lib.getExe pkgs.fuzzel;
notifyd = lib.getExe pkgs.mako;
wallpaperd = lib.getExe pkgs.hyprpaper;
wallpaperd = "${lib.getExe pkgs.swaybg} -i ${config.alyraffauf.desktop.theme.wallpaper}";
logout = lib.getExe pkgs.wlogout;
# lock = pkgs.hyprlock + "/bin/hyprlock --immediate";
# idled = pkgs.hypridle + "/bin/hypridle";
@ -155,7 +157,7 @@
env = QT_QPA_PLATFORMTHEME,${qt_platform_theme}
# Execute necessary apps
exec-once = ${wallpaperd}
exec-once = ${if config.alyraffauf.desktop.hyprland.randomWallpaper then "" else "${wallpaperd}"}
exec-once = ${bar}
exec-once = ${notifyd}
exec-once = ${lib.getExe' pkgs.wl-clipboard "wl-paste"} --type image --watch ${lib.getExe pkgs.cliphist} store

View file

@ -1,27 +0,0 @@
{
pkgs,
lib,
config,
inputs,
...
}: {
imports = [./hyprpaper-random.nix];
options = {
alyraffauf.desktop.hyprland.hyprpaper.enable =
lib.mkEnableOption "Enables hyprpaper and assorted wallpapers.";
};
config = lib.mkIf config.alyraffauf.desktop.hyprland.hyprpaper.enable {
# Packages that should be installed to the user profile.
home.packages = with pkgs; [inputs.nixpkgsUnstable.legacyPackages."${pkgs.system}".hyprpaper];
xdg.configFile."hypr/hyprpaper.conf".text = ''
preload = ${config.alyraffauf.desktop.theme.wallpaper}
wallpaper = ,${config.alyraffauf.desktop.theme.wallpaper}
splash = false
'';
};
}

View file

@ -1,36 +0,0 @@
{
pkgs,
lib,
config,
...
}: let
hyprpaper-random = pkgs.writeShellScriptBin "hyprpaper-random" ''
directory=${config.home.homeDirectory}/.local/share/backgrounds
if [ -d "$directory" ]; then
while true; do
sleep 30
${config.wayland.windowManager.hyprland.package}/bin/hyprctl hyprpaper unload all
monitor=`${config.wayland.windowManager.hyprland.package}/bin/hyprctl monitors | grep Monitor | awk '{print $2}'`
for m in ''${monitor[@]}; do
random_background=$(ls $directory/*.{png,jpg} | shuf -n 1)
${config.wayland.windowManager.hyprland.package}/bin/hyprctl hyprpaper preload $random_background
${config.wayland.windowManager.hyprland.package}/bin/hyprctl hyprpaper wallpaper "$m,$random_background"
done
sleep 870
done
fi
'';
in {
options = {
alyraffauf.desktop.hyprland.hyprpaper.randomWallpaper =
lib.mkEnableOption "Enables hyprpaper random wallpaper script.";
};
config = lib.mkIf config.alyraffauf.desktop.hyprland.hyprpaper.randomWallpaper {
# Packages that should be installed to the user profile.
home.packages = with pkgs; [hyprpaper-random];
wayland.windowManager.hyprland.extraConfig = "exec-once = ${hyprpaper-random}/bin/hyprpaper-random";
};
}

View file

@ -0,0 +1,41 @@
{
pkgs,
lib,
config,
...
}: let
hyprbg-randomWallpaper = pkgs.writeShellScriptBin "hyprbg-randomWallpaper" ''
kill `pidof swaybg`
OLD_PIDS=()
directory=${config.home.homeDirectory}/.local/share/backgrounds
if [ -d "$directory" ]; then
while true; do
NEW_PIDS=()
monitor=`${config.wayland.windowManager.hyprland.package}/bin/hyprctl monitors | grep Monitor | awk '{print $2}'`
for m in ''${monitor[@]}; do
random_background=$(ls $directory/*.{png,jpg} | shuf -n 1)
${lib.getExe pkgs.swaybg} -o $m -i $random_background &
NEW_PIDS+=($!)
done
sleep 5
for pid in ''${OLD_PIDS[@]}; do
kill $pid
done
OLD_PIDS=$NEW_PIDS
sleep 895
done
fi
'';
in {
config = lib.mkIf config.alyraffauf.desktop.hyprland.randomWallpaper {
home.packages = with pkgs; [swaybg hyprbg-randomWallpaper];
wayland.windowManager.hyprland.extraConfig = "exec-once = ${lib.getExe hyprbg-randomWallpaper}";
};
}

View file

@ -114,7 +114,7 @@
bar = lib.getExe pkgs.waybar;
launcher = lib.getExe pkgs.fuzzel;
notifyd = lib.getExe pkgs.mako;
wallpaperd = lib.getExe pkgs.swaybg;
wallpaperd = "${lib.getExe pkgs.swaybg} -i ${config.alyraffauf.desktop.theme.wallpaper}";
logout = lib.getExe pkgs.wlogout;
lock = lib.getExe pkgs.swaylock;
idled =
@ -356,7 +356,12 @@
};
startup = [
# {command = "${bar}";}
{command = "${wallpaperd}";}
{
command =
if config.alyraffauf.desktop.sway.randomWallpaper
then ""
else "${wallpaperd}";
}
{command = "${fileManager} --daemon";}
{command = "${idled}";}
{command = "${notifyd}";}