diff options
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperAutoChange.sh | 13 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperEffects.sh | 42 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperRandom.sh | 15 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperSelect.sh | 21 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WeatherWrap.sh | 6 |
5 files changed, 53 insertions, 44 deletions
diff --git a/config/hypr/UserScripts/WallpaperAutoChange.sh b/config/hypr/UserScripts/WallpaperAutoChange.sh index faec6335..5cee2a1e 100755 --- a/config/hypr/UserScripts/WallpaperAutoChange.sh +++ b/config/hypr/UserScripts/WallpaperAutoChange.sh @@ -13,13 +13,11 @@ # NOTE: this script uses bash (not POSIX shell) for the RANDOM variable wallust_refresh=$HOME/.config/hypr/scripts/RefreshNoWaybar.sh +SCRIPTSDIR="$HOME/.config/hypr/scripts" +# shellcheck source=/dev/null +. "$SCRIPTSDIR/WallpaperCmd.sh" focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}') -if command -v awww >/dev/null 2>&1; then - WWW="awww" -else - WWW="swww" -fi if [[ $# -lt 1 ]] || [[ ! -d $1 ]]; then echo "Usage: @@ -41,12 +39,13 @@ while true; do done \ | sort -n | cut -d':' -f2- \ | while read -r img; do - $WWW img -o $focused_monitor "$img" + resize_mode="$(wallpaper_resize_mode "$img" "$focused_monitor")" + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$img" # Regenerate colors from the exact image path to avoid cache races $HOME/.config/hypr/scripts/WallustSwww.sh "$img" # Refresh UI components that depend on wallust output $wallust_refresh sleep $INTERVAL - + done done diff --git a/config/hypr/UserScripts/WallpaperEffects.sh b/config/hypr/UserScripts/WallpaperEffects.sh index e1c8fe83..297c77fa 100755 --- a/config/hypr/UserScripts/WallpaperEffects.sh +++ b/config/hypr/UserScripts/WallpaperEffects.sh @@ -12,13 +12,10 @@ terminal=kitty wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" wallpaper_output="$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified" SCRIPTSDIR="$HOME/.config/hypr/scripts" +# shellcheck source=/dev/null +. "$SCRIPTSDIR/WallpaperCmd.sh" focused_monitor=$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name') rofi_theme="$HOME/.config/rofi/config-wallpaper-effect.rasi" -if command -v awww >/dev/null 2>&1; then - WWW="awww" -else - WWW="swww" -fi # Directory for swaync iDIR="$HOME/.config/swaync/images" @@ -29,10 +26,10 @@ FPS=60 TYPE="wipe" DURATION=2 BEZIER=".43,1.19,1,.4" -if [[ "$WWW" == "swww" || "$WWW" == "awww" ]]; then - SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION --transition-bezier $BEZIER" +if [[ "$WWW_CMD" == "swww" || "$WWW_CMD" == "awww" ]]; then + SWWW_PARAMS=(--transition-fps "$FPS" --transition-type "$TYPE" --transition-duration "$DURATION" --transition-bezier "$BEZIER") else - SWWW_PARAMS="" + SWWW_PARAMS=() fi # Define ImageMagick effects @@ -59,12 +56,15 @@ declare -A effects=( # Function to apply no effects no-effects() { - $WWW img -o "$focused_monitor" "$wallpaper_current" $SWWW_PARAMS && - wait $! - wallust run "$wallpaper_current" -s && - wait $! + local resize_mode + resize_mode="$(wallpaper_resize_mode "$wallpaper_current" "$focused_monitor")" + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$wallpaper_current" "${SWWW_PARAMS[@]}" || return 1 + if ! "$SCRIPTSDIR/WallustSwww.sh" "$wallpaper_current"; then + notify-send -u critical -i "$iDIR/error.png" "Wallust failed" "Wallpaper theme not refreshed" + return 1 + fi # Refresh rofi, waybar, wallust palettes - sleep 2 + sleep 0.5 "$SCRIPTSDIR/Refresh.sh" notify-send -u low -i "$iDIR/ja.png" "No wallpaper" "effects applied" @@ -90,19 +90,21 @@ main() { # Apply selected effect notify-send -u normal -i "$iDIR/ja.png" "Applying:" "$choice effects" eval "${effects[$choice]}" - + # intial kill process for pid in swaybg mpvpaper; do killall -SIGUSR1 "$pid" done sleep 1 - $WWW img -o "$focused_monitor" "$wallpaper_output" $SWWW_PARAMS & - - sleep 2 - - wallust run "$wallpaper_output" -s & - sleep 1 + local resize_mode + resize_mode="$(wallpaper_resize_mode "$wallpaper_output" "$focused_monitor")" + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$wallpaper_output" "${SWWW_PARAMS[@]}" + sleep 0.5 + if ! "$SCRIPTSDIR/WallustSwww.sh" "$wallpaper_output"; then + notify-send -u critical -i "$iDIR/error.png" "Wallust failed" "Wallpaper theme not refreshed" + return 1 + fi # Refresh rofi, waybar, wallust palettes "${SCRIPTSDIR}/Refresh.sh" notify-send -u low -i "$iDIR/ja.png" "$choice" "effects applied" diff --git a/config/hypr/UserScripts/WallpaperRandom.sh b/config/hypr/UserScripts/WallpaperRandom.sh index 70f051f7..aae80426 100755 --- a/config/hypr/UserScripts/WallpaperRandom.sh +++ b/config/hypr/UserScripts/WallpaperRandom.sh @@ -25,20 +25,23 @@ TYPE="random" DURATION=1 BEZIER=".43,1.19,1,.4" if [[ "$WWW_CMD" == "swww" || "$WWW_CMD" == "awww" ]]; then - SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION --transition-bezier $BEZIER" + SWWW_PARAMS=(--transition-fps "$FPS" --transition-type "$TYPE" --transition-duration "$DURATION" --transition-bezier "$BEZIER") else - SWWW_PARAMS="" + SWWW_PARAMS=() fi if ! "$WWW_CMD" query >/dev/null 2>&1; then "$WWW_DAEMON" "${WWW_DAEMON_ARGS[@]}" & fi - -"$WWW_CMD" img -o "$focused_monitor" "$RANDOMPICS" $SWWW_PARAMS +resize_mode="$(wallpaper_resize_mode "$RANDOMPICS" "$focused_monitor")" +"$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$RANDOMPICS" "${SWWW_PARAMS[@]}" wait $! -"$SCRIPTSDIR/WallustSwww.sh" "$RANDOMPICS" && +if ! "$SCRIPTSDIR/WallustSwww.sh" "$RANDOMPICS"; then + notify-send -u critical "Wallust failed" "Wallpaper theme not refreshed" + exit 1 +fi wait $! -sleep 2 +sleep 0.5 "$SCRIPTSDIR/Refresh.sh" diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index 31c7969a..2e5ecd86 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -27,9 +27,9 @@ TYPE="any" DURATION=2 BEZIER=".43,1.19,1,.4" if [[ "$WWW_CMD" == "swww" || "$WWW_CMD" == "awww" ]]; then - SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION --transition-bezier $BEZIER" + SWWW_PARAMS=(--transition-fps "$FPS" --transition-type "$TYPE" --transition-duration "$DURATION" --transition-bezier "$BEZIER") else - SWWW_PARAMS="" + SWWW_PARAMS=() fi @@ -173,11 +173,13 @@ apply_image_wallpaper() { "$WWW_CMD" query >/dev/null 2>&1 && break sleep 0.1 done - "$WWW_CMD" img -o "$focused_monitor" "$image_path" $SWWW_PARAMS || { + local resize_mode + resize_mode="$(wallpaper_resize_mode "$image_path" "$focused_monitor")" + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$image_path" "${SWWW_PARAMS[@]}" || { sleep 0.2 - "$WWW_CMD" img -o "$focused_monitor" "$image_path" $SWWW_PARAMS + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$image_path" "${SWWW_PARAMS[@]}" } - "$WWW_CMD" img -o "$focused_monitor" "$image_path" $SWWW_PARAMS + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$image_path" "${SWWW_PARAMS[@]}" # Persist per-monitor wallpaper selection mkdir -p "$(dirname "$per_monitor_wallpaper_current")" "$(dirname "$per_monitor_wallpaper_link")" @@ -185,10 +187,13 @@ apply_image_wallpaper() { cp -f "$image_path" "$per_monitor_wallpaper_current" || true # Run additional scripts (pass the image path to avoid cache race conditions) - "$SCRIPTSDIR/WallustSwww.sh" "$image_path" - sleep 2 + if ! "$SCRIPTSDIR/WallustSwww.sh" "$image_path"; then + notify-send -i "$iDIR/error.png" "Wallust failed" "Wallpaper theme not refreshed" + return 1 + fi + sleep 0.5 "$SCRIPTSDIR/Refresh.sh" - sleep 1 + sleep 0.3 } diff --git a/config/hypr/UserScripts/WeatherWrap.sh b/config/hypr/UserScripts/WeatherWrap.sh index a95bbd51..d2952d76 100755 --- a/config/hypr/UserScripts/WeatherWrap.sh +++ b/config/hypr/UserScripts/WeatherWrap.sh @@ -17,15 +17,15 @@ check_network() { if ping -c1 -W1 8.8.8.8 >/dev/null 2>&1; then return 0 fi - + if ping -c1 -W1 1.1.1.1 >/dev/null 2>&1; then return 0 fi - + if curl -s --connect-timeout 2 "https://ipinfo.io" >/dev/null 2>&1; then return 0 fi - + return 1 } |
