48 lines
1.5 KiB
Nix
48 lines
1.5 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}: {
|
|
options = {
|
|
desktop.hyprland.rofi.wallpaper.enable = lib.mkEnableOption "enable Rofi wallpaper module";
|
|
};
|
|
|
|
config = lib.mkIf config.desktop.hyprland.rofi.wallpaper.enable {
|
|
home.packages = with pkgs; [
|
|
(writeShellScriptBin "wallswitch-rofi" ''
|
|
WALLPAPER_DIR="$HOME/Pictures/backgrounds"
|
|
TMP_DIR="/tmp/rofi-wallpapers"
|
|
mkdir -p "$TMP_DIR"
|
|
|
|
# Generate preview list with image name and icon path
|
|
WALLPAPERS=$(find "$WALLPAPER_DIR" -type f \( -iname "*.jpg" -o -iname "*.png" -o -iname "*.jpeg" \))
|
|
|
|
ROFI_LIST=""
|
|
for wp in $WALLPAPERS; do
|
|
filename=$(basename "$wp")
|
|
# Generate thumbnail using imagemagick or copy if small
|
|
thumb_path="$TMP_DIR/''${filename}.png"
|
|
if [[ ! -f "$thumb_path" ]]; then
|
|
convert "$wp" -resize 100x100 "$thumb_path"
|
|
fi
|
|
ROFI_LIST+="$filename\x00icon\x1f$thumb_path\n"
|
|
done
|
|
|
|
SELECTED=$(echo -e "$ROFI_LIST" | rofi -dmenu "Select Wallpaper")
|
|
|
|
[[ -z "$SELECTED" ]] && exit 1
|
|
|
|
# Set the selected wallpaper
|
|
SELECTED_PATH="$WALLPAPER_DIR/$SELECTED"
|
|
|
|
# Update hyprpaper config (if needed) and reload
|
|
sleep 0.5 # Give it a moment to start
|
|
hyprctl hyprpaper unload all
|
|
hyprctl hyprpaper preload "$SELECTED_PATH"
|
|
hyprctl hyprpaper wallpaper "eDP-1,$SELECTED_PATH"
|
|
'')
|
|
];
|
|
};
|
|
}
|