-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwall.sh
More file actions
executable file
·48 lines (39 loc) · 1.6 KB
/
wall.sh
File metadata and controls
executable file
·48 lines (39 loc) · 1.6 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
#!/bin/bash
WALLPAPERS_DIR="$HOME/Pictures/wallpapers/"
CACHE_DIR="${HOME}/.cache/wallpapers"
HYPRPAPER_CONF="$HOME/.config/hypr/hyprpaper.conf"
BLUR="50x30"
BLURRED_WALLPAPER="$HOME/.cache/wallpaper_blurred.png"
ROFI_THEME_WAL="$HOME/.config/rofi/themes/style-3/wallpaper.rasi"
generate_cache () {
# Create cache dir if not exists
if [ ! -d "${CACHE_DIR}" ] ; then
mkdir -p "${CACHE_DIR}"
fi
rofi_override="element-icon{size:100px;border-radius:0px;}"
# Convert images in directory and save to cache dir
for imagen in "$WALLPAPERS_DIR"/*.{jpg,jpeg,png,webp}; do
if [ -f "$imagen" ]; then
nombre_archivo=$(basename "$imagen")
if [ ! -f "$CACHE_DIR/${nombre_archivo}" ] ; then
magick "$imagen" -strip -thumbnail 500x500^ -gravity center -extent 500x500 "$CACHE_DIR/${nombre_archivo}"
fi
fi
done
}
setwallpaper () {
cp $1 ~/.cache/wallpaper
magick $1 -blur $BLUR $BLURRED_WALLPAPER
magick "$1" -strip -thumbnail 500x500^ -gravity center -extent 500x500 "$HOME/.cache/fastfetch"
swww img $1 --transition-type center
}
sendnotification () {
notify-send -a $1 $2 -t 1000 -i $3
}
generate_cache
WALLPAPER=$(find "${WALLPAPERS_DIR}" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.webp" \) -exec basename {} \; | sort | while read -r A ; do echo -en "$A\x00icon\x1f""${CACHE_DIR}"/"$A\n" ; done | rofi -dmenu -theme $ROFI_THEME_WAL -p "wallpaper")
if [[ -n "$WALLPAPER" ]]; then
echo $WALLPAPER
setwallpaper $WALLPAPERS_DIR$WALLPAPER
sendnotification 'wall.sh' 'Wallpaper changed.' $WALLPAPERS_DIR/$WALLPAPER
fi