-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallpaper_change.sh
More file actions
executable file
·88 lines (78 loc) · 2.43 KB
/
Copy pathwallpaper_change.sh
File metadata and controls
executable file
·88 lines (78 loc) · 2.43 KB
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
#!/bin/bash
# Config
monitor="DP-1"
monitor2="DP-2"
hdmi="HDMI-A-1"
laptop="eDP-1"
wallpaper_dir="$HOME/Pictures/Wallpapers"
time_stamp_file="$HOME/.last_hyprpaper_run"
hyprpaper_conf="$HOME/.config/hypr/hyprpaper.conf"
CURRENT_WALL=$(hyprctl hyprpaper listloaded)
# Get list of wallpaper file paths
file_listing=($wallpaper_dir/*)
function hyprpaper_set_main() {
# Get one random file path
file_random=("${file_listing[RANDOM % ${#file_listing[@]}]}")
hyprpaper reload "$laptop, /home/enrico/Pictures/Wallpapers/cherry.webp"
}
function hyprpaper_set_secondary() {
# Set wallpaper with hyprctl
file_random=("${file_listing[RANDOM % ${#file_listing[@]}]}")
sleep 2
if [[ $(hyprctl monitors | awk '/Monitor/ {print $2}') == $monitor ]]; then
hyprctl hyprpaper reload "$monitor,$file_random"
elif [[ $(hyprctl monitors | awk '/Monitor/ {print $2}') == $monitor2 ]]; then
hyprctl hyprpaper reload "$monitor2,$file_random"
elif [[ $(hyprctl monitors | awk '/Monitor/ {print $2}') == $laptop ]]; then
hyprctl hyprpaper reload "$laptop,$file_random"
elif [[ $(hyprctl monitors | awk '/Monitor/ {print $2}') == $hdmi ]]; then
hyprctl hyprpaper reload "$hdmi,$file_random"
else
notify-send "Something wrong happened"
exit 1
fi
}
function swaybg_set {
file_random=("${file_listing[RANDOM % ${#file_listing[@]}]}")
if pgrep swaybg; then
pkill -9 swaybg
swaybg --image $file_random
if [ $file_random -eq "io_e_lei.jpg"]; then
swaybg --image $file_random --mode center
fi
else
swaybg --image $file_random
fi
}
function update_hyprpaperconf {
sed -i '/preload/d' $hyprpaper_conf
for x in $(ls $wallpaper_dir);
do
echo preload = $wallpaper_dir/$x >> $hyprpaper_conf
done
}
update_hyprpaperconf
# Check if the script was run less than a second ago
if [ -f "$time_stamp_file" ]; then
last_run=$(cat "$time_stamp_file")
current_time=$(date +%s)
time_diff=$((current_time - last_run))
if [ "$time_diff" -lt "1" ]; then
echo "Please wait a second before running the script again."
exit 1
fi
fi
# Save the current timestamp
date +%s > "$time_stamp_file"
# Call the function
if [ $DESKTOP_SESSION == hyprland ]; then
hyprpaper_set_secondary
elif [ $DESKTOP_SESSION == sway ]; then
swaybg_set
elif [ $DESKTOP_SESSION == plasma ]; then
file_random=("${file_listing[RANDOM % ${#file_listing[@]}]}")
plasma-apply-wallpaperimage $file_random
else
notify-send "Not a compatible desktop"
exit 1
fi