Files
dotfiles/hypr/scripts/random_wallpaper.sh
Nikolai Papin e251ac2fff feat: reserved screen space keybind and pinning windows for watching shows in the background;
refactor: waybar adjustments;
refactor: swaync idle inhibitor now handles idle state correctly;
feat: rmpc config
2025-09-22 17:48:56 +03:00

74 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
WALLPAPER_DIR="$HOME/Pictures/Wallpapers/current/"
INTRO_DIR="$HOME/Pictures/Wallpapers/intro/"
DELAY=5m
intro() {
if [ -z "$(ls -A "$WALLPAPER_DIR")" ]; then
echo "Current wallpaper folder is empty, nothing to do"
sleep 1
exit 0
fi
WALLPAPER=$(find "$INTRO_DIR" -type l | shuf -n 1)
while true; do
if hyprctl hyprpaper reload ,"$WALLPAPER"; then
sleep 1.5
break
fi
sleep 0.1
done
}
random_wallpaper() {
# Check if folder is not empty
if [ -z "$(ls -A "$WALLPAPER_DIR")" ]; then
echo "Current wallpaper folder is empty, nothing to do"
exit 0
fi
CURRENT_WALL=$(hyprctl hyprpaper listloaded)
# Get a random wallpaper that is not the current one
WALLPAPER=$(find "$WALLPAPER_DIR" -type l ! -name "$(basename "$CURRENT_WALL")" | shuf -n 1)
# Apply the selected wallpaper
hyprctl hyprpaper reload $1,"$WALLPAPER"
if [ $? -ne 0 ]; then
echo "The previous command failed."
# Handle the error here
hyprpaper &
sleep 1
hyprctl hyprpaper reload ,"$WALLPAPER"
fi
echo "Set random wallpaper to $WALLPAPER"
sleep 5
}
loop() {
while true; do
hyprctl hyprpaper listactive
if [ $? == 0 ]; then
break
fi
sleep 1
done
while true; do
hyprctl hyprpaper unload all
# TODO: get monitors dynamically
random_wallpaper "eDP-1"
random_wallpaper "HDMI-A-1"
sleep "$DELAY"
done
}
loop