blob: c989adf32a98dce33280dc237a7e3f92dc684136 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/bash
# WALLPAPERS PATH
DIR=$HOME/Pictures/wallpapers
# Transition config
FPS=30
TYPE="simple"
DURATION=3
SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION"
# Check if swaybg is running
if pidof swaybg > /dev/null; then
pkill swaybg
fi
# Retrieve image files
PICS=($(ls "${DIR}" | grep -E ".jpg$|.jpeg$|.png$|.gif$"))
RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}"
RANDOM_PIC_NAME="${#PICS[@]}. random"
# Rofi command
rofi_command="rofi -dmenu -config ~/.config/rofi/config-short.rasi"
menu() {
for i in "${!PICS[@]}"; do
# Displaying .gif to indicate animated images
if [[ -z $(echo "${PICS[$i]}" | grep .gif$) ]]; then
printf "$i. $(echo "${PICS[$i]}" | cut -d. -f1)\n"
else
printf "$i. ${PICS[$i]}\n"
fi
done
printf "$RANDOM_PIC_NAME"
}
swww query || swww init
main() {
choice=$(menu | ${rofi_command})
# No choice case
if [[ -z $choice ]]; then
exit 0
fi
# Random choice case
if [ "$choice" = "$RANDOM_PIC_NAME" ]; then
swww img "${DIR}/${RANDOM_PIC}" $SWWW_PARAMS
exit 0
fi
pic_index=$(echo "$choice" | cut -d. -f1)
swww img "${DIR}/${PICS[$pic_index]}" $SWWW_PARAMS
}
# Check if rofi is already running
if pidof rofi > /dev/null; then
pkill rofi
exit 0
fi
main
$HOME/.config/hypr/scripts/PywalSwww.sh &
$HOME/.config/hypr/scripts/Refresh.sh
|