Update switchwall.sh

Updated video image
This commit is contained in:
Souyama
2025-05-21 08:20:05 +05:30
committed by GitHub
parent cfe48fb0a1
commit 13cb540e49
@@ -1,16 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
CONFIG_DIR="$XDG_CONFIG_HOME/ags" CONFIG_DIR="$XDG_CONFIG_HOME/ags"
CACHE_DIR="$XDG_CACHE_HOME/ags"
THUMBNAIL_DIR="/tmp/mpvpaper_thumbnails"
CUSTOM_DIR="$XDG_CONFIG_HOME/hypr/custom" CUSTOM_DIR="$XDG_CONFIG_HOME/hypr/custom"
RESTORE_SCRIPT_DIR="$CUSTOM_DIR/scripts" RESTORE_SCRIPT_DIR="$CUSTOM_DIR/scripts"
RESTORE_SCRIPT="$RESTORE_SCRIPT_DIR/__restore_video_wallpaper.sh" RESTORE_SCRIPT="$RESTORE_SCRIPT_DIR/__restore_video_wallpaper.sh"
VIDEO_OPTS="no-audio loop hwdec=auto scale=bilinear interpolation=no video-sync=display-resample panscan=1.0 video-scale-x=1.0 video-scale-y=1.0 video-align-x=0.5 video-align-y=0.5" VIDEO_OPTS="no-audio loop hwdec=auto scale=bilinear interpolation=no video-sync=display-resample panscan=1.0 video-scale-x=1.0 video-scale-y=1.0 video-align-x=0.5 video-align-y=0.5"
mkdir -p "$THUMBNAIL_DIR"
mkdir -p "$RESTORE_SCRIPT_DIR" mkdir -p "$RESTORE_SCRIPT_DIR"
is_video() { is_video() {
@@ -19,8 +19,8 @@ is_video() {
} }
kill_existing_mpvpaper() { kill_existing_mpvpaper() {
# Abort all mpvpapers' instance # Abort all mpvpapers' instance
pkill -f -9 mpvpaper || true pkill -f -9 mpvpaper || true
} }
create_restore_script() { create_restore_script() {
@@ -34,8 +34,8 @@ create_restore_script() {
pkill -f -9 mpvpaper pkill -f -9 mpvpaper
for monitor in \$(hyprctl monitors -j | jq -r '.[] | .name'); do for monitor in \$(hyprctl monitors -j | jq -r '.[] | .name'); do
mpvpaper -o "$VIDEO_OPTS" "\$monitor" "$video_path" & mpvpaper -o "$VIDEO_OPTS" "\$monitor" "$video_path" &
sleep 0.1 sleep 0.1
done done
EOF EOF
@@ -94,12 +94,17 @@ switch() {
sleep 0.1 sleep 0.1
done done
# We take the first frame of video to colorgen # We take the first frame of video to colorgen and swww
thumbnail="$THUMBNAIL_DIR/$(basename "$imgpath").jpg" thumbnail="$CACHE_DIR"/user/generated/mpvpaper_thumbnail.jpg
ffmpeg -y -i "$imgpath" -vframes 1 "$thumbnail" 2>/dev/null ffmpeg -y -i "$imgpath" -vframes 1 "$thumbnail" 2>/dev/null
if [ -f "$thumbnail" ]; then if [ -f "$thumbnail" ]; then
# Apply swww wallpaper using the thumbnail
swww img "$thumbnail" --transition-step 100 --transition-fps 120 \
--transition-type grow --transition-angle 30 --transition-duration 1 \
--transition-pos "$cursorposx, $cursorposy_inverted"
"$CONFIG_DIR"/scripts/color_generation/colorgen.sh "$thumbnail" --apply --smart "$CONFIG_DIR"/scripts/color_generation/colorgen.sh "$thumbnail" --apply --smart
create_restore_script "$video_path" create_restore_script "$video_path"
else else
echo "Cannot create image to colorgen" echo "Cannot create image to colorgen"
@@ -128,6 +133,6 @@ elif [[ "$1" ]]; then
else else
# Select and set image (hyprland) # Select and set image (hyprland)
cd "$(xdg-user-dir PICTURES)/Wallpapers" || cd "$(xdg-user-dir PICTURES)" || return 1 cd "$(xdg-user-dir PICTURES)/Wallpapers" || cd "$(xdg-user-dir PICTURES)" || return 1
switch "$(yad --width 1200 --height 800 --file --add-preview --large-preview --title='Choose wallpaper')" switch "$(yad --width 1200 --height 800 --file --add-preview --large-preview --title='Choose wallpaper')"
fi fi