feat: random wallpaper on startup

This commit is contained in:
hesam-init 2024-02-14 21:49:38 +03:30
parent b3fecd0ba7
commit 88296d593b
2 changed files with 1 additions and 10 deletions

View file

@ -1,11 +1,9 @@
#!/usr/bin/env bash
source $HOME/.config/hypr/scripts/env.sh
if [[ $(pidof swaybg) ]]; then
pkill swaybg
fi
swww query || swww init
swww img $wallpapers_dir/macos.jpg --transition-fps $swww_fps --transition-type any --transition-duration $swww_duration
exec $HOME/.config/hypr/scripts/swww-random.sh

View file

@ -2,16 +2,13 @@
source $HOME/.config/hypr/scripts/env.sh
# Get only files from the directory
files=($(find "${wallpapers_dir}" -type f))
# Check if there are any files
if [ ${#files[@]} -eq 0 ]; then
echo "No files found in the directory: ${wallpapers_dir}"
exit 1
fi
# Filter files to include only those identified as images by the 'file' command
image_files=()
for file in "${files[@]}"; do
if file -b --mime-type "$file" | grep -q "^image/"; then
@ -19,15 +16,11 @@ for file in "${files[@]}"; do
fi
done
# Check if there are any image files
if [ ${#image_files[@]} -eq 0 ]; then
echo "No image files found in the directory: ${wallpapers_dir}"
exit 1
fi
# Get a random image from the array
random_pic=${image_files[$RANDOM % ${#image_files[@]}]}
echo $random_pic
swww img "$random_pic" --transition-fps $swww_fps --transition-type any --transition-duration $swww_duration