#!/usr/bin/env bash
# __        ______    _____  __  __           _
# \ \      / /  _ \  | ____|/ _|/ _| ___  ___| |_ ___
#  \ \ /\ / /| |_) | |  _| | |_| |_ / _ \/ __| __/ __|
#   \ V  V / |  __/  | |___|  _|  _|  __/ (__| |_\__ \
#    \_/\_/  |_|     |_____|_| |_|  \___|\___|\__|___/
#

# Notifications
source "$HOME/.config/ml4w/scripts/ml4w-notification-handler"
APP_NAME="Waypaper"
NOTIFICATION_ICON="preferences-desktop-wallpaper-symbolic"

ml4w_cache_folder="$HOME/.cache/ml4w/hyprland-dotfiles"

# Get current wallpaper
cache_file="$ml4w_cache_folder/current_wallpaper"

# Open rofi to select the wallpaper effects
options="$(ls ~/.config/hypr/effects/wallpaper/)\noff"

# Open rofi
choice=$(echo -e "$options" | rofi -dmenu -replace -config ~/.config/rofi/config-themes.rasi -i -no-show-icons -l 5 -width 30)
if [ ! -z $choice ]; then
    echo "$choice" > "$HOME/.config/ml4w/settings/wallpaper-effect"
    $HOME/.config/ml4w/scripts/ml4w-wallpaper "$(cat $cache_file)"
fi
