cycles instead of random wallpaper
This commit is contained in:
parent
8240f7d218
commit
7b6447b8d5
1 changed files with 30 additions and 12 deletions
|
@ -1,18 +1,36 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
DIR=$HOME/Desktop/wallpapers
|
#!/bin/bash
|
||||||
PICS=($(ls ${DIR}))
|
|
||||||
|
|
||||||
# Select a random wallpaper
|
# Directory containing wallpapers
|
||||||
RANDOMPICS=${PICS[$RANDOM % ${#PICS[@]}]}
|
WALLPAPER_DIR="$HOME/Desktop/wallpapers"
|
||||||
|
|
||||||
# Notify the user about the wallpaper change
|
# File to keep track of the current wallpaper index
|
||||||
dunstify "⬅️Changed" -a "Wallpaper" -u "low" -i ${DIR}/${RANDOMPICS} -r "1234"
|
INDEX_FILE="$HOME/.current_wallpaper_index"
|
||||||
|
|
||||||
# Preload the selected wallpaper and set it as the wallpaper
|
# Find images in the wallpaper directory (supports .jpg, .jpeg, and .png)
|
||||||
hyprctl hyprpaper preload "${DIR}/${RANDOMPICS}"
|
wallpapers=($(find "$WALLPAPER_DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \)))
|
||||||
hyprctl hyprpaper wallpaper ",${DIR}/${RANDOMPICS}"
|
|
||||||
|
|
||||||
# Play a notification sound
|
# Check if any wallpapers are found
|
||||||
canberra-gtk-play -i window-attention
|
if [[ ${#wallpapers[@]} -eq 0 ]]; then
|
||||||
|
echo "No wallpapers found in the directory: $WALLPAPER_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read the current index from the file or set it to 0 if it doesn't exist
|
||||||
|
if [[ -f $INDEX_FILE ]]; then
|
||||||
|
current_index=$(cat $INDEX_FILE)
|
||||||
|
else
|
||||||
|
current_index=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Calculate the next index, looping back to 0 if needed
|
||||||
|
next_index=$(( (current_index + 1) % ${#wallpapers[@]} ))
|
||||||
|
|
||||||
|
# Set the next wallpaper
|
||||||
|
next_wallpaper="${wallpapers[$next_index]}"
|
||||||
|
hyprctl hyprpaper preload "$next_wallpaper"
|
||||||
|
hyprctl hyprpaper wallpaper eDP-1,"$next_wallpaper"
|
||||||
|
|
||||||
|
# Save the new index to the file
|
||||||
|
echo $next_index > $INDEX_FILE
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue