aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/WallpaperSelect.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/UserScripts/WallpaperSelect.sh')
-rwxr-xr-xconfig/hypr/UserScripts/WallpaperSelect.sh86
1 files changed, 67 insertions, 19 deletions
diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh
index ed0b2846..9dafdf57 100755
--- a/config/hypr/UserScripts/WallpaperSelect.sh
+++ b/config/hypr/UserScripts/WallpaperSelect.sh
@@ -1,5 +1,10 @@
#!/usr/bin/env bash
-# /* ---- 💫 https://github.com/LinuxBeginnings 💫 ---- */
+# ==================================================
+# KoolDots (2026)
+# Project URL: https://github.com/LinuxBeginnings
+# License: GNU GPLv3
+# SPDX-License-Identifier: GPL-3.0-or-later
+# ==================================================
# This script for selecting wallpapers (SUPER W)
# WALLPAPERS PATH
@@ -7,18 +12,25 @@ terminal=kitty
PICTURES_DIR="$(xdg-user-dir PICTURES 2>/dev/null || echo "$HOME/Pictures")"
wallDIR="$PICTURES_DIR/wallpapers"
SCRIPTSDIR="$HOME/.config/hypr/scripts"
+# shellcheck source=/dev/null
+. "$SCRIPTSDIR/WallpaperCmd.sh"
wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current"
+wallpaper_link="$HOME/.config/rofi/.current_wallpaper"
# Directory for swaync
iDIR="$HOME/.config/swaync/images"
iDIRi="$HOME/.config/swaync/icons"
-# swww transition config
+# swww transition config (only when using swww)
FPS=60
TYPE="any"
DURATION=2
BEZIER=".43,1.19,1,.4"
-SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION --transition-bezier $BEZIER"
+if [[ "$WWW_CMD" == "swww" ]]; then
+ SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION --transition-bezier $BEZIER"
+else
+ SWWW_PARAMS=""
+fi
# Check if package bc exists
if ! command -v bc &>/dev/null; then
@@ -46,7 +58,7 @@ rofi_override="element-icon{size:${adjusted_icon_size}%;}"
# Kill existing wallpaper daemons for video
kill_wallpaper_for_video() {
- swww kill 2>/dev/null
+ "$WWW_CMD" kill 2>/dev/null
pkill mpvpaper 2>/dev/null
pkill swaybg 2>/dev/null
pkill hyprpaper 2>/dev/null
@@ -66,7 +78,19 @@ mapfile -d '' PICS < <(find -L "${wallDIR}" -type f \( \
-iname "*.mp4" -o -iname "*.mkv" -o -iname "*.mov" -o -iname "*.webm" \) -print0)
RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}"
-RANDOM_PIC_NAME=". random"
+RANDOM_PIC_NAME="$(basename "$RANDOM_PIC")"
+
+CURRENT_MON_PIC_PATH=$("$WWW_CMD" query 2>/dev/null | grep "$focused_monitor" | awk '{print $NF}')
+if [[ -z "$CURRENT_MON_PIC_PATH" ]]; then
+ if [[ -L "$wallpaper_link" ]]; then
+ CURRENT_MON_PIC_PATH="$(readlink -f "$wallpaper_link")"
+ elif [[ -f "$wallpaper_link" ]]; then
+ CURRENT_MON_PIC_PATH="$wallpaper_link"
+ elif [[ -f "$wallpaper_current" ]]; then
+ CURRENT_MON_PIC_PATH="$wallpaper_current"
+ fi
+fi
+CURRENT_MON_PIC_NAME=$(basename "$CURRENT_MON_PIC_PATH")
# Rofi command
rofi_command="rofi -i -show -dmenu -config $rofi_theme -theme-str $rofi_override"
@@ -75,7 +99,10 @@ rofi_command="rofi -i -show -dmenu -config $rofi_theme -theme-str $rofi_override
menu() {
IFS=$'\n' sorted_options=($(sort <<<"${PICS[*]}"))
- printf "%s\x00icon\x1f%s\n" "$RANDOM_PIC_NAME" "$RANDOM_PIC"
+ printf "%s\x00icon\x1f%s\n" "Random: $RANDOM_PIC_NAME" "$RANDOM_PIC"
+ if [[ -n "$CURRENT_MON_PIC_PATH" ]]; then
+ printf "%s\x00icon\x1f%s\n" "Current: $CURRENT_MON_PIC_NAME" "$CURRENT_MON_PIC_PATH"
+ fi
for pic_path in "${sorted_options[@]}"; do
pic_name=$(basename "$pic_path")
@@ -107,6 +134,7 @@ modify_startup_config() {
# Check if it's a live wallpaper (video)
if [[ "$selected_file" =~ \.(mp4|mkv|mov|webm)$ ]]; then
# For video wallpapers:
+ sed -i '/^\s*exec-once\s*=\s*\$scriptsDir\/WallpaperDaemon\.sh\s*$/s/^/\#/' "$startup_config"
sed -i '/^\s*exec-once\s*=\s*swww-daemon\s*--format\s*xrgb\s*$/s/^/\#/' "$startup_config"
sed -i '/^\s*#\s*exec-once\s*=\s*mpvpaper\s*.*$/s/^#\s*//;' "$startup_config"
@@ -117,6 +145,7 @@ modify_startup_config() {
echo "Configured for live wallpaper (video)."
else
# For image wallpapers:
+ sed -i '/^\s*#\s*exec-once\s*=\s*\$scriptsDir\/WallpaperDaemon\.sh\s*$/s/^\s*#\s*//;' "$startup_config"
sed -i '/^\s*#\s*exec-once\s*=\s*swww-daemon\s*--format\s*xrgb\s*$/s/^\s*#\s*//;' "$startup_config"
sed -i '/^\s*exec-once\s*=\s*mpvpaper\s*.*$/s/^/\#/' "$startup_config"
@@ -131,12 +160,20 @@ apply_image_wallpaper() {
kill_wallpaper_for_image
- if ! pgrep -x "swww-daemon" >/dev/null; then
- echo "Starting swww-daemon..."
- swww-daemon --format xrgb &
+ if ! pgrep -x "$WWW_DAEMON" >/dev/null; then
+ echo "Starting $WWW_DAEMON..."
+ "$WWW_DAEMON" "${WWW_DAEMON_ARGS[@]}" &
fi
-
- swww img -o "$focused_monitor" "$image_path" $SWWW_PARAMS
+ # Wait for daemon to be ready before applying
+ for _ in {1..20}; do
+ "$WWW_CMD" query >/dev/null 2>&1 && break
+ sleep 0.1
+ done
+ "$WWW_CMD" img -o "$focused_monitor" "$image_path" $SWWW_PARAMS || {
+ sleep 0.2
+ "$WWW_CMD" img -o "$focused_monitor" "$image_path" $SWWW_PARAMS
+ }
+ "$WWW_CMD" img -o "$focused_monitor" "$image_path" $SWWW_PARAMS
# Run additional scripts (pass the image path to avoid cache race conditions)
"$SCRIPTSDIR/WallustSwww.sh" "$image_path"
@@ -165,21 +202,32 @@ main() {
choice=$(menu | $rofi_command)
choice=$(echo "$choice" | xargs)
RANDOM_PIC_NAME=$(echo "$RANDOM_PIC_NAME" | xargs)
+ raw_choice="$choice"
+ choice="${choice#Random: }"
+ choice="${choice#Current: }"
if [[ -z "$choice" ]]; then
echo "No choice selected. Exiting."
exit 0
fi
- # Handle random selection correctly
- if [[ "$choice" == "$RANDOM_PIC_NAME" ]]; then
- choice=$(basename "$RANDOM_PIC")
- fi
-
- choice_basename=$(basename "$choice" | sed 's/\(.*\)\.[^.]*$/\1/')
+ # Resolve selection directly when using Random/Current entries
+ if [[ "$raw_choice" == Random:\ * ]]; then
+ selected_file="$RANDOM_PIC"
+ elif [[ "$raw_choice" == Current:\ * && -n "$CURRENT_MON_PIC_PATH" ]]; then
+ selected_file="$CURRENT_MON_PIC_PATH"
+ elif [[ -f "$choice" ]]; then
+ selected_file="$choice"
+ else
+ # Handle random selection by name when needed
+ if [[ "$choice" == "$RANDOM_PIC_NAME" ]]; then
+ choice=$(basename "$RANDOM_PIC")
+ fi
+ choice_basename=$(basename "$choice" | sed 's/\(.*\)\.[^.]*$/\1/')
- # Search for the selected file in the wallpapers directory, including subdirectories
- selected_file=$(find "$wallDIR" -iname "$choice_basename.*" -print -quit)
+ # Search for the selected file in the wallpapers directory, including subdirectories
+ selected_file=$(find "$wallDIR" -iname "$choice_basename.*" -print -quit)
+ fi
if [[ -z "$selected_file" ]]; then
echo "File not found. Selected choice: $choice"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage