89 lines
2 KiB
Bash
Executable file
89 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# borrowed from https://github.com/JaKooLit/wallpaper-switcher/
|
|
|
|
# WALLPAPERS PATH
|
|
DIR=$HOME/.config/hypr/wallpapers
|
|
|
|
# Transition config (type swww img --help for more settings
|
|
FPS=30
|
|
TYPE="outer"
|
|
DURATION=3
|
|
|
|
# wofi window config (in %)
|
|
WIDTH=30
|
|
HEIGHT=55
|
|
|
|
SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION"
|
|
|
|
|
|
PICS=($(ls ${DIR} | grep -e ".jpg$" -e ".jpeg$" -e ".png$" -e ".gif$"))
|
|
|
|
RANDOM_PIC=${PICS[ $RANDOM % ${#PICS[@]} ]}
|
|
RANDOM_PIC_NAME="${#PICS[@]}. random"
|
|
|
|
|
|
# WOFI STYLES
|
|
CONFIG=$HOME/.config/hypr/scripts/wofi_wallpaper_switcher.conf
|
|
|
|
# to check if swaybg is running
|
|
|
|
if [[ $(pidof swaybg) ]]; then
|
|
pkill swaybg
|
|
fi
|
|
|
|
## Wofi Command
|
|
wofi_command="wofi --show dmenu \
|
|
--prompt choose...
|
|
--conf $CONFIG \
|
|
--width=$WIDTH% --height=$HEIGHT% \
|
|
--cache-file=/dev/null \
|
|
--hide-scroll --no-actions \
|
|
--matching=fuzzy"
|
|
|
|
menu(){
|
|
# Here we are looping in the PICS array that is composed of all images in the $DIR
|
|
# folder
|
|
for i in ${!PICS[@]}; do
|
|
# get full path of the image
|
|
path=${DIR}/${PICS[$i]}
|
|
# keeping the .gif to make sue you know it is animated
|
|
if [[ -z $(echo ${PICS[$i]} | grep .gif$) ]]; then
|
|
printf "img:${path}:text:$(echo ${PICS[$i]} | cut -d. -f1)\n" # n°. <name_of_file_without_identifier>
|
|
else
|
|
printf "img:${path}:text:${PICS[$i]}\n"
|
|
fi
|
|
done
|
|
}
|
|
|
|
swww query || swww-daemon
|
|
|
|
main() {
|
|
choice=$(menu | ${wofi_command})
|
|
|
|
# no choice case
|
|
if [[ -z $choice ]]; then return; fi
|
|
|
|
# random choice case
|
|
if [ "$choice" = "$RANDOM_PIC_NAME" ]; then
|
|
swww img ${DIR}/${RANDOM_PIC} $SWWW_PARAMS
|
|
return
|
|
fi
|
|
|
|
pic_path=$(echo $choice | cut -d: -f2)
|
|
echo $pic_path
|
|
swww img ${pic_path} $SWWW_PARAMS
|
|
}
|
|
|
|
# Check if wofi is already running
|
|
if pidof wofi >/dev/null; then
|
|
killall wofi
|
|
exit 0
|
|
else
|
|
main
|
|
fi
|
|
|
|
# Uncomment to launch something if a choice was made
|
|
# if [[ -n "$choice" ]]; then
|
|
# Restart Waybar
|
|
# fi
|