From 7d04d1d840598781b0a93a0ac91ba8fd9d5ac06c Mon Sep 17 00:00:00 2001 From: kenji Date: Sat, 27 Dec 2025 20:09:43 -0600 Subject: [PATCH] add: wallpaper changer --- apps/hyprland/hypr/rules.nix | 9 +++++++++ apps/hyprpaper/switch-wallpaper.nix | 22 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/hyprland/hypr/rules.nix b/apps/hyprland/hypr/rules.nix index 85aef05..c1f6eac 100644 --- a/apps/hyprland/hypr/rules.nix +++ b/apps/hyprland/hypr/rules.nix @@ -5,6 +5,15 @@ "float, class:^(org\.hakase\.popup\..*)$" "animation slide right, class:^(org\.hakase\.popup\..*)$" "dimaround, class:^(org\.hakase\.popup\..*)$" + # --- WALLPAPER PICKER --- + "float, class:^(wallpaper-selector)$" + "float, initialTitle:^(Wallpaper Selector)$" + "center, class:^(wallpaper-selector)$" + "center, initialTitle:^(Wallpaper Selector)$" + "size 60% 60%, class:^(wallpaper-selector)$" + "size 60% 60%, initialTitle:^(Wallpaper Selector)$" + "dimaround, class:^(wallpaper-selector)$" + "dimaround, initialTitle:^(Wallpaper Selector)$" # Prevent Firefox and Terminal from stealing focus on launch "suppressevent activate, workspace:20" diff --git a/apps/hyprpaper/switch-wallpaper.nix b/apps/hyprpaper/switch-wallpaper.nix index e054f78..115b5ca 100644 --- a/apps/hyprpaper/switch-wallpaper.nix +++ b/apps/hyprpaper/switch-wallpaper.nix @@ -1,17 +1,35 @@ {pkgs, ...}: { home.packages = with pkgs; [ - (writeShellScriptBin "switch-wallpaper" '' + (writeShellScriptBin "hakase-wallpaper-switch" '' + if [[ "$1" != "run" ]]; 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...'" + exit 0 + 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...'" + exit 0 + fi + fi + tmp_file=$(mktemp) target_dir="$HOME/.config/nixos/assets/Wallpapers" if [ ! -d "$target_dir" ]; then target_dir="$HOME" fi + # Ensure we are in a terminal that supports yazi ${pkgs.yazi}/bin/yazi "$target_dir" --chooser-file="$tmp_file" + + if [ ! -f "$tmp_file" ]; then + echo "No selection file created." + exit 1 + fi + WALLPAPER=$(cat "$tmp_file") rm -f "$tmp_file" if [ -z "$WALLPAPER" ]; then + echo "No wallpaper selected." exit 0 fi @@ -20,7 +38,7 @@ ${pkgs.hyprland}/bin/hyprctl hyprpaper preload "$WALLPAPER" ${pkgs.hyprland}/bin/hyprctl hyprpaper wallpaper ",$WALLPAPER" - exec matugen image $WALLPAPER + exec matugen image "$WALLPAPER" '') ]; }