♻️ refactor(hypr): changed wallpaper selection code

This commit is contained in:
Sergio Laín 2023-10-11 13:36:51 +02:00
parent 862ae6225e
commit d7b60abfa1
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
6 changed files with 30 additions and 26 deletions

View file

@ -59,7 +59,7 @@ bind=SUPER, space, exec, wleave
bind=SUPER,Insert,exec, ~/.config/hypr/scripts/color_picker
# Wallpaper
bind=SUPERSHIFT,w,exec, ~/.config/hypr/scripts/rofi/wallpaper_selection
bind=SUPERSHIFT,w,exec, ~/.config/hypr/scripts/wallpaper select
# Keybindings Cheatsheet
bind=SUPER,i,exec, ~/.config/hypr/scripts/rofi/keybindings

View file

@ -10,6 +10,10 @@ pypr &
# Notification Daemon
swaync &
# Wallpaper Backend
swww init &
./wallpaper random
# Bar
waybar &
@ -22,9 +26,6 @@ udiskie &
# Notify about devices connecting and disconnecting
devify &
# Wallpaper
$scripts/random_wallpaper &
# Idle daemon to screen lock
/home/matt/.config/sway/idle.sh &

View file

@ -1,10 +0,0 @@
#!/usr/bin/bash
function load_wp() {
IMAGE=$(fd -e png -e jpg --base-directory "$HOME/.config/hypr/themes/luna/walls/" --type f . | shuf -n 1)
swww img --transition-type wipe --transition-pos top-right --transition-duration 3.8 --transition-step 255 $HOME/.config/hypr/themes/luna/walls/"$IMAGE"
}
swww init
load_wp

View file

@ -1,11 +0,0 @@
#!/usr/bin/bash
function load_wp() {
# IMAGE=$(fd -e png -e jpg --base-directory "$HOME/.config/hypr/themes/luna/walls/" --type f . | shuf -n 1)
IMAGE=$(rofi -show file-browser-extended -theme ~/.config/rofi/style.rasi -file-browser-stdout -file-browser-dir $HOME/.config/hypr/themes/luna/walls/)
swww img --transition-type wipe --transition-pos top-right --transition-duration 3.8 --transition-step 255 "$IMAGE"
}
swww init
load_wp

24
.config/hypr/scripts/wallpaper Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/bash
mode=$1
if [ -z "$mode" ]; then
echo "Usage: $0 [select|random]"
exit 1
fi
if [ "$mode" == "select" ]; then
IMAGE=$(rofi -show file-browser-extended -theme ~/.config/rofi/style.rasi -file-browser-stdout -file-browser-dir $HOME/.config/hypr/themes/luna/walls/)
if [ -z "$IMAGE" ]; then
exit 1
fi
elif [ "$mode" == "random" ]; then
RANDOM_IMAGE=$(fd -e png -e jpg --base-directory "$HOME/.config/hypr/themes/luna/walls/" --type f . | shuf -n 1)
IMAGE="$HOME/.config/hypr/themes/luna/walls/$RANDOM_IMAGE"
else
exit 1
fi
swww img --transition-type wipe --transition-pos top-right --transition-duration 3.8 --transition-step 255 "$IMAGE"
notify-send "Wallpaper Changed" "Wallpaper changed to $IMAGE"

View file

@ -3,7 +3,7 @@ Description=Change wallpaper with swww as backend
[Service]
Type=simple
ExecStart=/home/matt/.config/hypr/scripts/random_wallpaper
ExecStart=/home/matt/.config/hypr/scripts/wallpaper random
[Install]
WantedBy=default.target