58 lines
1.8 KiB
Nix
58 lines
1.8 KiB
Nix
{pkgs, ...}: {
|
|
# FIXME: please revise to use uwsm and xdg-terminal-exec
|
|
# also, add features and fix the following:
|
|
# * multiple wallpapers
|
|
# * day/noon/night wallpaper
|
|
# * set first, default wallpaper to hyprland one-dark
|
|
# * be consistent in formatting!
|
|
|
|
# flow:
|
|
# Menu for options: 1. Single Wallpaper, 2. Multiple Wallpapers, 3. Timed Wallpapers
|
|
home.packages = with pkgs; [
|
|
(writeShellScriptBin "hakase-wallpaper-switch" ''
|
|
if [[ "$1" != "run" ]]; then
|
|
if command -v ghostty &> /dev/null; then
|
|
ghostty --class="org.hakase.switch-wallpaper" --title="Wallpaper Selector" -e bash -c "hakase-wallpaper-switch run || read -p 'Hit Enter to close...'"
|
|
exit 0
|
|
elif command -v kitty &> /dev/null; then
|
|
kitty --class org.hakase.switch-wallpaper --title "Wallpaper Selector" -e bash -c "hakase-wallpaper-switch run || read -p 'Hit Enter to close...'"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
tmp_file=$(mktemp)
|
|
target_dir="$HOME/Pictures/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
|
|
|
|
# Persistence logic
|
|
CACHE_FILE="$HOME/.cache/current_wallpaper"
|
|
cp "$WALLPAPER" "$CACHE_FILE"
|
|
|
|
# Reload hyprpaper
|
|
${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 "$CACHE_FILE"
|
|
'')
|
|
];
|
|
}
|