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
|
||||
PICS=($(ls ${DIR}))
|
||||
#!/bin/bash
|
||||
|
||||
# Select a random wallpaper
|
||||
RANDOMPICS=${PICS[$RANDOM % ${#PICS[@]}]}
|
||||
# Directory containing wallpapers
|
||||
WALLPAPER_DIR="$HOME/Desktop/wallpapers"
|
||||
|
||||
# Notify the user about the wallpaper change
|
||||
dunstify "⬅️Changed" -a "Wallpaper" -u "low" -i ${DIR}/${RANDOMPICS} -r "1234"
|
||||
# File to keep track of the current wallpaper index
|
||||
INDEX_FILE="$HOME/.current_wallpaper_index"
|
||||
|
||||
# Preload the selected wallpaper and set it as the wallpaper
|
||||
hyprctl hyprpaper preload "${DIR}/${RANDOMPICS}"
|
||||
hyprctl hyprpaper wallpaper ",${DIR}/${RANDOMPICS}"
|
||||
# Find images in the wallpaper directory (supports .jpg, .jpeg, and .png)
|
||||
wallpapers=($(find "$WALLPAPER_DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \)))
|
||||
|
||||
# Play a notification sound
|
||||
canberra-gtk-play -i window-attention
|
||||
# Check if any wallpapers are found
|
||||
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