45 lines
1.3 KiB
Nix
45 lines
1.3 KiB
Nix
{pkgs, ...}: {
|
|
home.packages = with pkgs; [
|
|
(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
|
|
|
|
# ${pkgs.hyprland}/bin/hyprctl hyprpaper unload all
|
|
|
|
${pkgs.hyprland}/bin/hyprctl hyprpaper preload "$WALLPAPER"
|
|
${pkgs.hyprland}/bin/hyprctl hyprpaper wallpaper ",$WALLPAPER"
|
|
|
|
exec matugen image "$WALLPAPER"
|
|
'')
|
|
];
|
|
}
|