fix: rofi wallpaper menu

This commit is contained in:
hesam-init 2024-02-24 02:45:19 +03:30
parent a53f2be3ef
commit 4a699437a3

View file

@ -6,20 +6,31 @@ dir="$HOME/.config/rofi/wallpaper/type-1"
theme='style-8' theme='style-8'
rofi_cmd() { rofi_cmd() {
rofi -dmenu -theme ${dir}/${theme}.rasi -p "Chad" rofi -dmenu -theme "${dir}/${theme}.rasi" -p "Chad"
} }
show_image_preview() { show_image_preview() {
ls --escape "$WALLPAPERS_DIR" | 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
while read A; do echo -en "$A\x00icon\x1f$WALLPAPERS_DIR/$A\n"; done echo -en "$A\x00icon\x1f$WALLPAPERS_DIR/$A\n"
done
} }
choice=$( set_wallpaper() {
show_image_preview | rofi_cmd 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