From 39ba3c402f2e86c3d7296fe6925f1bd896d0959e Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Thu, 9 May 2024 13:50:51 +0900 Subject: [PATCH] Wallpaper Select and Auto wallpaper change Script updated to be able to set wallpaper on focused monitor only. NOTE: you need awk --- config/hypr/UserScripts/WallpaperAutoChange.sh | 4 +++- config/hypr/UserScripts/WallpaperSelect.sh | 4 +++- config/hypr/scripts/PywalSwww.sh | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/hypr/UserScripts/WallpaperAutoChange.sh b/config/hypr/UserScripts/WallpaperAutoChange.sh index e52b7e9..9e0e1cb 100755 --- a/config/hypr/UserScripts/WallpaperAutoChange.sh +++ b/config/hypr/UserScripts/WallpaperAutoChange.sh @@ -9,6 +9,8 @@ pywal_refresh=$HOME/.config/hypr/scripts/RefreshNoWaybar.sh +focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}') + if [[ $# -lt 1 ]] || [[ ! -d $1 ]]; then echo "Usage: $0 " @@ -29,7 +31,7 @@ while true; do done \ | sort -n | cut -d':' -f2- \ | while read -r img; do - swww img "$img" + swww img -o $focused_monitor "$img" $pywal_refresh sleep $INTERVAL diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index de9c654..2616014 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -4,6 +4,8 @@ SCRIPTSDIR="$HOME/.config/hypr/scripts" +focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}') + # WALLPAPERS PATH wallDIR="$HOME/Pictures/wallpapers" @@ -67,7 +69,7 @@ main() { done if [[ $pic_index -ne -1 ]]; then - swww img "${wallDIR}/${PICS[$pic_index]}" $SWWW_PARAMS + swww img -o $focused_monitor "${wallDIR}/${PICS[$pic_index]}" $SWWW_PARAMS else echo "Image not found." exit 1 diff --git a/config/hypr/scripts/PywalSwww.sh b/config/hypr/scripts/PywalSwww.sh index 30a4d98..9f7b15b 100755 --- a/config/hypr/scripts/PywalSwww.sh +++ b/config/hypr/scripts/PywalSwww.sh @@ -11,8 +11,8 @@ monitor_outputs=($(ls "$cache_dir")) # Initialize a flag to determine if the ln command was executed ln_success=false -# Get first valid monitor -current_monitor=$(hyprctl -j monitors | jq -r '.[0].name') +# Get current focused monitor +current_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}') echo $current_monitor # Construct the full path to the cache file cache_file="$cache_dir$current_monitor"