From 9bd6342ba88278620080f0e2a1a76b9425e07050 Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Mon, 24 Jun 2024 14:54:02 +0200 Subject: [PATCH] Updates --- .install/packages/hyprland-packages.sh | 1 + hypr/conf/autostart.conf | 9 +- hypr/conf/keybindings/default.conf | 4 +- hypr/conf/ml4w.conf | 5 ++ hypr/scripts/wallpaper-post.sh | 115 +++++++++++++++++++++++++ waybar/modules.json | 2 +- waypaper/config.ini | 19 ++++ 7 files changed, 149 insertions(+), 6 deletions(-) create mode 100755 hypr/scripts/wallpaper-post.sh create mode 100644 waypaper/config.ini diff --git a/.install/packages/hyprland-packages.sh b/.install/packages/hyprland-packages.sh index f0274f5..4a2ee3c 100644 --- a/.install/packages/hyprland-packages.sh +++ b/.install/packages/hyprland-packages.sh @@ -16,4 +16,5 @@ packagesYay=( "nwg-look" "eww" "hyprshade" + "waypaper" ); diff --git a/hypr/conf/autostart.conf b/hypr/conf/autostart.conf index 1f5ddc7..91d7fae 100644 --- a/hypr/conf/autostart.conf +++ b/hypr/conf/autostart.conf @@ -20,15 +20,18 @@ exec-once = hypridle # Load cliphist history exec-once = wl-paste --watch cliphist store -# Initialize Wallpaper Engine -exec-once = ~/dotfiles/hypr/scripts/init-wallpaper-engine.sh - # Autostart ML4W App exec-once = ~/dotfiles/hypr/scripts/ml4w-welcome-autostart.sh # Start ewww daemon exec-once = ~/dotfiles/hypr/scripts/eww.sh +# Initialize waypaper +exec-once = waypaper --restore + +# Launch Waybar +exec-once = ~/dotfiles/waybar/launch.sh + # Start autostart cleanup exec-once = ~/dotfiles/hypr/scripts/cleanup.sh diff --git a/hypr/conf/keybindings/default.conf b/hypr/conf/keybindings/default.conf index 638118c..febd2e5 100644 --- a/hypr/conf/keybindings/default.conf +++ b/hypr/conf/keybindings/default.conf @@ -33,8 +33,8 @@ bind = $mainMod, G, togglegroup # Toggle window group bind = $mainMod SHIFT, A, exec, ~/dotfiles/hypr/scripts/toggle-animations.sh # Toggle animations bind = $mainMod, PRINT, exec, ~/dotfiles/hypr/scripts/screenshot.sh # Take a screenshot bind = $mainMod CTRL, Q, exec, wlogout # Start wlogout -bind = $mainMod SHIFT, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh # Change the wallpaper -bind = $mainMod CTRL, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh select # Open wallpaper selector +bind = $mainMod SHIFT, W, exec, waypaper --random # Change the wallpaper +bind = $mainMod CTRL, W, exec, waypaper # Open wallpaper selector bind = $mainMod CTRL, RETURN, exec, rofi -show drun -replace -i # Open application launcher bind = $mainMod CTRL, H, exec, ~/dotfiles/hypr/scripts/keybindings.sh # Show keybindings bind = $mainMod SHIFT, B, exec, ~/dotfiles/waybar/launch.sh # Reload waybar diff --git a/hypr/conf/ml4w.conf b/hypr/conf/ml4w.conf index 162daf4..2c5983e 100644 --- a/hypr/conf/ml4w.conf +++ b/hypr/conf/ml4w.conf @@ -7,6 +7,11 @@ windowrulev2 = float,class:(.*chat.openai.com.*) windowrulev2 = size 500 50%,class:(.*chat.openai.com.*) windowrulev2 = move 20 70,class:(.*chat.openai.com.*) +# ML4W Welcome App floating +windowrulev2 = float,class:(.*waypaper.*) +windowrulev2 = size 800 700,class:(.*waypaper.*) +windowrulev2 = center,class:(.*waypaper.*) + # ML4W Welcome App floating windowrulev2 = float,class:(com.ml4w.welcome) windowrulev2 = size 700 600,class:(com.ml4w.welcome) diff --git a/hypr/scripts/wallpaper-post.sh b/hypr/scripts/wallpaper-post.sh new file mode 100755 index 0000000..35d1bee --- /dev/null +++ b/hypr/scripts/wallpaper-post.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# _ _ +# __ ____ _| | |_ __ __ _ _ __ ___ _ __ +# \ \ /\ / / _` | | | '_ \ / _` | '_ \ / _ \ '__| +# \ V V / (_| | | | |_) | (_| | |_) | __/ | +# \_/\_/ \__,_|_|_| .__/ \__,_| .__/ \___|_| +# |_| |_| +# +# by Stephan Raabe (2024) +# ----------------------------------------------------- + +# ----------------------------------------------------- +# Get selected wallpaper +# ----------------------------------------------------- +echo ":: Using wallpaper $1" +wallpaper=$1 + +# ----------------------------------------------------- +# Check to use wallpaper cache +# ----------------------------------------------------- +use_cache=0 +if [ -f $HOME/dotfiles/.settings/wallpaper_cache ] ;then + use_cache=1 +fi + +if [ "$use_cache" == "1" ] ;then + echo ":: Using Wallpaper Cache" +else + echo ":: Wallpaper Cache disabled" +fi + +# ----------------------------------------------------- +# File and folder names +# ----------------------------------------------------- +force_generate=0 + +generated_versions="$HOME/.cache/ml4w-wallpaper-generated" +cache_file="$HOME/.cache/current_wallpaper" +used_wallpaper="$HOME/.cache/used_wallpaper" +blurred_wallpaper="$HOME/.cache/blurred_wallpaper.png" +square_wallpaper="$HOME/.cache/square_wallpaper.png" + +rasi_file="$HOME/.cache/current_wallpaper.rasi" +blur_file="$HOME/dotfiles/.settings/blur.sh" + +blur="50x30" +blur=$(cat $blur_file) + +# Create rasi file if not exists +if [ ! -f $rasi_file ] ;then + touch $rasi_file + echo "* { current-image: url(\"$wallpaper_folder/default.jpg\", height); }" > "$rasi_file" +fi + +# Create folder with generated versions of wallpaper if not exists +if [ ! -d $generated_versions ] ;then + mkdir $generated_versions +fi + +# ----------------------------------------------------- +# Current wallpaper +# ----------------------------------------------------- +current_wallpaper=$wallpaper +current_wallpaper_filename=$(basename $current_wallpaper) +echo ":: Current Wallpaper: $current_wallpaper" +echo ":: Current Wallpaper Filename: $current_wallpaper_filename" +used_wallpaper=$wallpaper +newwall=$current_wallpaper_filename + +# ----------------------------------------------------- +# Execute pywal +# ----------------------------------------------------- +echo ":: Execute wallpaper" +wal -q -i $wallpaper +source "$HOME/.cache/wal/colors.sh" + +# ----------------------------------------------------- +# Created blurred wallpaper +# ----------------------------------------------------- +if [ -f $generated_versions/blur-$blur-$newwall.png ] && [ "$force_generate" == "0" ] && [ "$use_cache" == "1" ] ;then + echo ":: Use cached wallpaper blur-$blur-$newwall.png" +else + echo ":: Generate new cached wallpaper blur-$blur-$newwall with blur $blur" + if [ "$1" == "init" ] ;then + echo ":: Init" + else + dunstify "Creating blurred version ..." "with image $newwall" -h int:value:50 -h string:x-dunst-stack-tag:wallpaper + fi + magick $used_wallpaper -resize 75% $blurred_wallpaper + echo ":: Resized to 75%" + if [ ! "$blur" == "0x0" ] ;then + magick $blurred_wallpaper -blur $blur $blurred_wallpaper + cp $blurred_wallpaper $generated_versions/blur-$blur-$newwall.png + echo ":: Blurred" + fi + cp $generated_versions/blur-$blur-$newwall.png $blurred_wallpaper +fi +cp $generated_versions/blur-$blur-$newwall.png $blurred_wallpaper + +# ----------------------------------------------------- +# Created square wallpaper +# ----------------------------------------------------- +if [ -f $generated_versions/square-$newwall.png ] && [ "$force_generate" == "0" ] && [ "$use_cache" == "1" ] ;then + echo ":: Use cached wallpaper square-$newwall.png" +else + echo ":: Generate new cached wallpaper square-$newwall" + if [ "$1" == "init" ] ;then + echo ":: Init" + else + dunstify "Creating square version ..." "with image $newwall" -h int:value:75 -h string:x-dunst-stack-tag:wallpaper + fi + magick $wallpaper -gravity Center -extent 1:1 $square_wallpaper + cp $square_wallpaper $generated_versions/square-$newwall.png +fi +cp $generated_versions/square-$newwall.png $square_wallpaper diff --git a/waybar/modules.json b/waybar/modules.json index b87b979..2a5077e 100644 --- a/waybar/modules.json +++ b/waybar/modules.json @@ -110,7 +110,7 @@ // Wallpaper "custom/wallpaper": { "format": "", - "on-click": "~/dotfiles/hypr/scripts/wallpaper.sh select", + "on-click": "waypaper", "on-click-right": "~/dotfiles/hypr/scripts/wallpaper-effects.sh", "tooltip-format": "Left: Select a wallpaper\nRight: Select wallpaper effect" }, diff --git a/waypaper/config.ini b/waypaper/config.ini new file mode 100644 index 0000000..a21bf4b --- /dev/null +++ b/waypaper/config.ini @@ -0,0 +1,19 @@ +[Settings] +language = en +folder = ~/wallpaper +wallpaper = ~/wallpaper/3d-tech.jpg +backend = hyprpaper +monitors = All +fill = fill +sort = name +color = #ffffff +subfolders = False +show_hidden = False +show_gifs_only = False +post_command = ~/dotfiles/hypr/scripts/wallpaper-post.sh $wallpaper +number_of_columns = 3 +swww_transition_type = any +swww_transition_step = 90 +swww_transition_angle = 0 +swww_transition_duration = 2 +