diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
| commit | c222e1bad2ba5e779c3af5b956906c82ead43271 (patch) | |
| tree | a5253e0861c200ff90354169e1f67ef42ebf0ef9 /config/hypr/scripts/WallpaperSelect.sh | |
| parent | bb0be21dba7980fc1c047eaba24eda1712bd7f31 (diff) | |
Initial upload
Diffstat (limited to 'config/hypr/scripts/WallpaperSelect.sh')
| -rwxr-xr-x | config/hypr/scripts/WallpaperSelect.sh | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/config/hypr/scripts/WallpaperSelect.sh b/config/hypr/scripts/WallpaperSelect.sh new file mode 100755 index 00000000..610d94cd --- /dev/null +++ b/config/hypr/scripts/WallpaperSelect.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# WALLPAPERS PATH +DIR=$HOME/Pictures/wallpapers + +# Transition config (type swww img --help for more settings +FPS=30 +TYPE="simple" +DURATION=3 + +# wofi window config (in %) +WIDTH=10 +HEIGHT=30 + +SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION" + +PICS=($(ls ${DIR} | grep -e ".jpg$" -e ".jpeg$" -e ".png$" -e ".gif$")) +#PICS=($(find ${DIR} -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" \))) + +RANDOM_PIC=${PICS[ $RANDOM % ${#PICS[@]} ]} +RANDOM_PIC_NAME="${#PICS[@]}. random" + +# WOFI STYLES +CONFIG="$HOME/.config/wofi/WofiBig/config" +STYLE="$HOME/.config/wofi/style.css" +COLORS="$HOME/.config/wofi/colors" + +# to check if swaybg is running +if [[ $(pidof swaybg) ]]; then + pkill swaybg +fi + +## Wofi Command +wofi_command="wofi --show dmenu \ + --prompt choose... + --conf $CONFIG --style $STYLE --color $COLORS \ + --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 + # keeping the .gif to make sue you know it is animated + if [[ -z $(echo ${PICS[$i]} | grep .gif$) ]]; then + printf "$i. $(echo ${PICS[$i]} | cut -d. -f1)\n" # n°. <name_of_file_without_identifier> + else + printf "$i. ${PICS[$i]}\n" + fi + done + + printf "$RANDOM_PIC_NAME" +} + +swww query || swww init + +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_index=$(echo $choice | cut -d. -f1) + swww img ${DIR}/${PICS[$pic_index]} $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
\ No newline at end of file |
