-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangewall
executable file
·102 lines (85 loc) · 1.68 KB
/
changewall
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
# mini swww wallpaper switcher with color support for waybar
# made by vodkaa (github.com/vodkaa-gal)
wall_dir="$HOME/Pictures/wallpapers"
wall_list=("$wall_dir"/*)
function chgwall_help {
printf "◤◢◤ CHANGEWALL USAGE ◢◤◢
changewall (i|n|p|s) [IMAGE_PATH]
i - init
n - next wallpaper
p - previous wallpaper
s - specify image\n"
}
function init {
xtrans="grow"
swww-daemon --format xrgb & disown
sleep 1
waybar & disown
}
function get_image {
current=$(swww query | awk -F 'image: ' '{print $2}' | tail -n 1)
if [ $order -eq 1 ]; then # reverse order if set to previous
wall_list=( $(printf '%s\n' "${wall_list[@]}" | tac) )
fi
final=0
for entry in "${wall_list[@]}"
do
if [ -f $entry ]; then # ignore directories
if [ $final == 1 ] # break if after current wallpaper
then
wall=$entry; break;
fi
if [ "$entry" == "$current" ]
then
final=1 # set pass checkpoint
fi
fi
done
if [ ! -f "$wall" ]; then # set to first file if next file does not exist
wall=$wall_list
fi
}
function set_wall {
if [ ! -f "$wall" ]; then # check if wall exists
printf "No file specified. \n"
exit
fi
wallust run --backend kmeans "$wall"
pywalfox update
swww img "$wall" \
--transition-bezier .43,1.19,1,.4 \
--transition-type grow \
--transition-duration 0.3 \
--transition-fps 60 \
--invert-y \
--transition-pos "$( hyprctl cursorpos )"
pkill waybar
waybar & disown
}
case $1 in
h|-h|help|--help)
chgwall_help
;;
i)
init
exit
;;
n)
order=0
get_image
;;
p)
order=1
get_image
;;
s)
wall=$2
;;
*)
chgwall_help
printf "\nErr: Incorrect usage.\n"
exit 1
;;
esac
set_wall