irongit
hygoland/UserScripts/WallpaperAutoChange.sh
39 lines1.0 KBBourne Again Shell (bash)
1#!/bin/bash
2# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
3# source https://wiki.archlinux.org/title/Hyprland#Using_a_script_to_change_wallpaper_every_X_minutes
4
5# This script will randomly go through the files of a directory, setting it
6# up as the wallpaper at regular intervals
7#
8# NOTE: this script uses bash (not POSIX shell) for the RANDOM variable
9
10wallust_refresh=$HOME/.config/hypr/scripts/RefreshNoWaybar.sh
11
12focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}')
13
14if [[ $# -lt 1 ]] || [[ ! -d $1 ]]; then
15 echo "Usage:
16 $0 <dir containing images>"
17 exit 1
18fi
19
20# Edit below to control the images transition
21export SWWW_TRANSITION_FPS=60
22export SWWW_TRANSITION_TYPE=simple
23
24# This controls (in seconds) when to switch to the next image
25INTERVAL=1800
26
27while true; do
28 find "$1" \
29 | while read -r img; do
30 echo "$((RANDOM % 1000)):$img"
31 done \
32 | sort -n | cut -d':' -f2- \
33 | while read -r img; do
34 swww img -o $focused_monitor "$img"
35 $wallust_refresh
36 sleep $INTERVAL
37
38 done
39done