From 4a699437a35a0dfda7451dd03097197d5f7384fb Mon Sep 17 00:00:00 2001 From: hesam-init Date: Sat, 24 Feb 2024 02:45:19 +0330 Subject: [PATCH] fix: rofi wallpaper menu --- .../rofi/wallpaper/type-1/wallpaper.sh | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh b/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh index 315bb8e..0fa98ac 100755 --- a/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh +++ b/hyprland/.config/rofi/wallpaper/type-1/wallpaper.sh @@ -6,20 +6,31 @@ dir="$HOME/.config/rofi/wallpaper/type-1" theme='style-8' rofi_cmd() { - rofi -dmenu -theme ${dir}/${theme}.rasi -p "Chad" + rofi -dmenu -theme "${dir}/${theme}.rasi" -p "Chad" } show_image_preview() { - ls --escape "$WALLPAPERS_DIR" | - while read A; do echo -en "$A\x00icon\x1f$WALLPAPERS_DIR/$A\n"; done + find "$WALLPAPERS_DIR" -maxdepth 1 -type f \( -iname \*.jpg -o -iname \*.jpeg -o -iname \*.png -o -iname \*.gif \) -exec basename {} \; | while read -r A; do + echo -en "$A\x00icon\x1f$WALLPAPERS_DIR/$A\n" + done } -choice=$( - show_image_preview | rofi_cmd -) +set_wallpaper() { + local wallpaper="$WALLPAPERS_DIR/$1" + if [ -f "$wallpaper" ]; then + swww img "$wallpaper" --transition-fps "$SWWW_FPS" --transition-type any --transition-duration "$SWWW_DURATION" + echo "Wallpaper set to: $wallpaper" + else + echo "Error: Wallpaper file not found: $wallpaper" + fi +} -wallpaper="$WALLPAPERS_DIR/$choice" +choice=$(show_image_preview | rofi_cmd) -swww img "$wallpaper" --transition-fps $SWWW_FPS --transition-type any --transition-duration $SWWW_DURATION +if [ -n "$choice" ]; then + set_wallpaper "$choice" +else + echo "No wallpaper selected." +fi -exit 1 +exit 0