improve: hakase-wallpaper-switch

This commit is contained in:
kenji
2025-12-27 20:31:19 -06:00
parent 7d04d1d840
commit 3f5f2fbcd6
3 changed files with 44 additions and 16 deletions
+4 -4
View File
@@ -6,13 +6,13 @@
"animation slide right, class:^(org\.hakase\.popup\..*)$" "animation slide right, class:^(org\.hakase\.popup\..*)$"
"dimaround, class:^(org\.hakase\.popup\..*)$" "dimaround, class:^(org\.hakase\.popup\..*)$"
# --- WALLPAPER PICKER --- # --- WALLPAPER PICKER ---
"float, class:^(wallpaper-selector)$" "float, class:^(org\.hakase\.switch-wallpaper)$"
"float, initialTitle:^(Wallpaper Selector)$" "float, initialTitle:^(Wallpaper Selector)$"
"center, class:^(wallpaper-selector)$" "center, class:^(org\.hakase\.switch-wallpaper)$"
"center, initialTitle:^(Wallpaper Selector)$" "center, initialTitle:^(Wallpaper Selector)$"
"size 60% 60%, class:^(wallpaper-selector)$" "size 60% 60%, class:^(org\.hakase\.switch-wallpaper)$"
"size 60% 60%, initialTitle:^(Wallpaper Selector)$" "size 60% 60%, initialTitle:^(Wallpaper Selector)$"
"dimaround, class:^(wallpaper-selector)$" "dimaround, class:^(org\.hakase\.switch-wallpaper)$"
"dimaround, initialTitle:^(Wallpaper Selector)$" "dimaround, initialTitle:^(Wallpaper Selector)$"
# Prevent Firefox and Terminal from stealing focus on launch # Prevent Firefox and Terminal from stealing focus on launch
+29 -6
View File
@@ -1,12 +1,35 @@
{myConfig, ...}: { {
pkgs,
config,
lib,
myConfig,
...
}: let
wallpaperDir = "${config.home.homeDirectory}/.config/nixos/assets/Wallpapers";
defaultWallpaper = "${wallpaperDir}/${myConfig.hyprland.wallpaper}";
cacheWallpaper = "${config.home.homeDirectory}/.cache/current_wallpaper";
in {
services.hyprpaper = { services.hyprpaper = {
enable = true; enable = true;
settings = { settings = {
# preload = ["../../assets/Wallpapers/${myConfig.hyprland.wallpaper}"]; preload = [cacheWallpaper];
# wallpaper = [ wallpaper = [
# "HDMI-A-1,../../assets/Wallpapers/${myConfig.hyprland.wallpaper}" ",${cacheWallpaper}"
# ]; ];
}; };
}; };
# systemd.user.startServices = "sd-switch";
home.activation.setupWallpaper = lib.hm.dag.entryAfter ["writeBoundary"] ''
if [ ! -f "${cacheWallpaper}" ]; then
mkdir -p "$(dirname "${cacheWallpaper}")"
if [ -f "${defaultWallpaper}" ]; then
cp "${defaultWallpaper}" "${cacheWallpaper}"
else
echo "Default wallpaper not found at ${defaultWallpaper}"
touch "${cacheWallpaper}"
fi
fi
'';
systemd.user.startServices = "sd-switch";
} }
+11 -6
View File
@@ -3,10 +3,10 @@
(writeShellScriptBin "hakase-wallpaper-switch" '' (writeShellScriptBin "hakase-wallpaper-switch" ''
if [[ "$1" != "run" ]]; then if [[ "$1" != "run" ]]; then
if command -v ghostty &> /dev/null; then if command -v ghostty &> /dev/null; then
ghostty --class="wallpaper-selector" --title="Wallpaper Selector" -e bash -c "switch-wallpaper run || read -p 'Hit Enter to close...'" ghostty --class="org.hakase.switch-wallpaper" --title="Wallpaper Selector" -e bash -c "hakase-wallpaper-switch run || read -p 'Hit Enter to close...'"
exit 0 exit 0
elif command -v kitty &> /dev/null; then elif command -v kitty &> /dev/null; then
kitty --class wallpaper-selector --title "Wallpaper Selector" -e bash -c "switch-wallpaper run || read -p 'Hit Enter to close...'" kitty --class org.hakase.switch-wallpaper --title "Wallpaper Selector" -e bash -c "hakase-wallpaper-switch run || read -p 'Hit Enter to close...'"
exit 0 exit 0
fi fi
fi fi
@@ -33,12 +33,17 @@
exit 0 exit 0
fi fi
# ${pkgs.hyprland}/bin/hyprctl hyprpaper unload all # Persistence logic
CACHE_FILE="$HOME/.cache/current_wallpaper"
cp "$WALLPAPER" "$CACHE_FILE"
${pkgs.hyprland}/bin/hyprctl hyprpaper preload "$WALLPAPER" # Reload hyprpaper
${pkgs.hyprland}/bin/hyprctl hyprpaper wallpaper ",$WALLPAPER" ${pkgs.hyprland}/bin/hyprctl hyprpaper unload all
${pkgs.hyprland}/bin/hyprctl hyprpaper preload "$CACHE_FILE"
${pkgs.hyprland}/bin/hyprctl hyprpaper wallpaper ",$CACHE_FILE"
exec matugen image "$WALLPAPER" exec matugen image "$CACHE_FILE"
'') '')
]; ];
} }