From d7b60abfa108efd1df738e928996fa44214c2aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Wed, 11 Oct 2023 13:36:51 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(hypr):=20changed?= =?UTF-8?q?=20wallpaper=20selection=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/hypr/keybinds/binds.conf | 2 +- .config/hypr/scripts/autostart | 7 +++--- .config/hypr/scripts/random_wallpaper | 10 -------- .config/hypr/scripts/rofi/wallpaper_selection | 11 --------- .config/hypr/scripts/wallpaper | 24 +++++++++++++++++++ .config/systemd/user/change_wallpaper.service | 2 +- 6 files changed, 30 insertions(+), 26 deletions(-) delete mode 100755 .config/hypr/scripts/random_wallpaper delete mode 100755 .config/hypr/scripts/rofi/wallpaper_selection create mode 100755 .config/hypr/scripts/wallpaper diff --git a/.config/hypr/keybinds/binds.conf b/.config/hypr/keybinds/binds.conf index bd3ab9bf..1330b25d 100644 --- a/.config/hypr/keybinds/binds.conf +++ b/.config/hypr/keybinds/binds.conf @@ -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 diff --git a/.config/hypr/scripts/autostart b/.config/hypr/scripts/autostart index 8b353d83..30a9e825 100755 --- a/.config/hypr/scripts/autostart +++ b/.config/hypr/scripts/autostart @@ -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 & diff --git a/.config/hypr/scripts/random_wallpaper b/.config/hypr/scripts/random_wallpaper deleted file mode 100755 index 86f9c216..00000000 --- a/.config/hypr/scripts/random_wallpaper +++ /dev/null @@ -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 diff --git a/.config/hypr/scripts/rofi/wallpaper_selection b/.config/hypr/scripts/rofi/wallpaper_selection deleted file mode 100755 index 358d993b..00000000 --- a/.config/hypr/scripts/rofi/wallpaper_selection +++ /dev/null @@ -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 diff --git a/.config/hypr/scripts/wallpaper b/.config/hypr/scripts/wallpaper new file mode 100755 index 00000000..a17c3ba7 --- /dev/null +++ b/.config/hypr/scripts/wallpaper @@ -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" diff --git a/.config/systemd/user/change_wallpaper.service b/.config/systemd/user/change_wallpaper.service index 5af5f94a..ec515e52 100644 --- a/.config/systemd/user/change_wallpaper.service +++ b/.config/systemd/user/change_wallpaper.service @@ -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