forked from Shinonome/dots-hyprland
allow video wallpaper
This commit is contained in:
@@ -27,6 +27,47 @@ post_process() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
THUMBNAIL_DIR="/tmp/mpvpaper_thumbnails"
|
||||||
|
CUSTOM_DIR="$XDG_CONFIG_HOME/hypr/custom"
|
||||||
|
RESTORE_SCRIPT_DIR="$CUSTOM_DIR/scripts"
|
||||||
|
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"
|
||||||
|
|
||||||
|
is_video() {
|
||||||
|
local extension="${1##*.}"
|
||||||
|
[[ "$extension" == "mp4" || "$extension" == "mkv" || "$extension" == "webm" ]] && return 0 || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
kill_existing_mpvpaper() {
|
||||||
|
pkill -f -9 mpvpaper || true
|
||||||
|
}
|
||||||
|
|
||||||
|
create_restore_script() {
|
||||||
|
local video_path=$1
|
||||||
|
cat > "$RESTORE_SCRIPT.tmp" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
# Generated by switchwall.sh - Don't modify it by yourself.
|
||||||
|
# Time: $(date)
|
||||||
|
|
||||||
|
pkill -f -9 mpvpaper
|
||||||
|
|
||||||
|
for monitor in \$(hyprctl monitors -j | jq -r '.[] | .name'); do
|
||||||
|
mpvpaper -o "$VIDEO_OPTS" "\$monitor" "$video_path" &
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
EOF
|
||||||
|
mv "$RESTORE_SCRIPT.tmp" "$RESTORE_SCRIPT"
|
||||||
|
chmod +x "$RESTORE_SCRIPT"
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_restore() {
|
||||||
|
cat > "$RESTORE_SCRIPT.tmp" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
# The content of this script will be generated by switchwall.sh - Don't modify it by yourself.
|
||||||
|
EOF
|
||||||
|
mv "$RESTORE_SCRIPT.tmp" "$RESTORE_SCRIPT"
|
||||||
|
}
|
||||||
|
|
||||||
switch() {
|
switch() {
|
||||||
imgpath="$1"
|
imgpath="$1"
|
||||||
mode_flag="$2"
|
mode_flag="$2"
|
||||||
@@ -48,8 +89,54 @@ switch() {
|
|||||||
echo 'Aborted'
|
echo 'Aborted'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
matugen_args=(image "$imgpath")
|
|
||||||
generate_colors_material_args=(--path "$imgpath")
|
kill_existing_mpvpaper
|
||||||
|
|
||||||
|
if is_video "$imgpath"; then
|
||||||
|
mkdir -p "$THUMBNAIL_DIR"
|
||||||
|
|
||||||
|
missing_deps=()
|
||||||
|
if ! command -v mpvpaper &> /dev/null; then
|
||||||
|
missing_deps+=("mpvpaper")
|
||||||
|
fi
|
||||||
|
if ! command -v ffmpeg &> /dev/null; then
|
||||||
|
missing_deps+=("ffmpeg")
|
||||||
|
fi
|
||||||
|
if [ ${#missing_deps[@]} -gt 0 ]; then
|
||||||
|
echo "Missing deps: ${missing_deps[*]}"
|
||||||
|
echo "Arch: yay -S ${missing_deps[*]}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
local video_path="$imgpath"
|
||||||
|
monitors=$(hyprctl monitors -j | jq -r '.[] | .name')
|
||||||
|
for monitor in $monitors; do
|
||||||
|
mpvpaper -o "$VIDEO_OPTS" "$monitor" "$video_path" &
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Extract first frame for color generation
|
||||||
|
thumbnail="$THUMBNAIL_DIR/$(basename "$imgpath").jpg"
|
||||||
|
ffmpeg -y -i "$imgpath" -vframes 1 "$thumbnail" 2>/dev/null
|
||||||
|
|
||||||
|
if [ -f "$thumbnail" ]; then
|
||||||
|
matugen_args=(image "$thumbnail")
|
||||||
|
generate_colors_material_args=(--path "$thumbnail")
|
||||||
|
create_restore_script "$video_path"
|
||||||
|
else
|
||||||
|
echo "Cannot create image to colorgen"
|
||||||
|
remove_restore
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
matugen_args=(image "$imgpath")
|
||||||
|
generate_colors_material_args=(--path "$imgpath")
|
||||||
|
# Set wallpaper with swww
|
||||||
|
swww img "$imgpath" --transition-step 100 --transition-fps 120 \
|
||||||
|
--transition-type grow --transition-angle 30 --transition-duration 1 \
|
||||||
|
--transition-pos "$cursorposx, $cursorposy_inverted"
|
||||||
|
remove_restore
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine mode if not set
|
# Determine mode if not set
|
||||||
@@ -62,18 +149,14 @@ switch() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Dark/light mode, material scheme
|
|
||||||
[[ -n "$mode_flag" ]] && matugen_args+=(--mode "$mode_flag") && generate_colors_material_args+=(--mode "$mode_flag")
|
[[ -n "$mode_flag" ]] && matugen_args+=(--mode "$mode_flag") && generate_colors_material_args+=(--mode "$mode_flag")
|
||||||
[[ -n "$type_flag" ]] && matugen_args+=(--type "$type_flag") && generate_colors_material_args+=(--scheme "$type_flag")
|
[[ -n "$type_flag" ]] && matugen_args+=(--type "$type_flag") && generate_colors_material_args+=(--scheme "$type_flag")
|
||||||
# Terminal scheme
|
|
||||||
generate_colors_material_args+=(--termscheme "$terminalscheme" --blend_bg_fg)
|
generate_colors_material_args+=(--termscheme "$terminalscheme" --blend_bg_fg)
|
||||||
generate_colors_material_args+=(--cache "$STATE_DIR/user/color.txt")
|
generate_colors_material_args+=(--cache "$STATE_DIR/user/color.txt")
|
||||||
|
|
||||||
pre_process
|
pre_process
|
||||||
|
|
||||||
# Generate with matugen
|
|
||||||
matugen "${matugen_args[@]}"
|
matugen "${matugen_args[@]}"
|
||||||
# Use custom script for mixing (matugen can't D:)
|
|
||||||
source "$(eval echo $ILLOGICAL_IMPULSE_VIRTUAL_ENV)/bin/activate"
|
source "$(eval echo $ILLOGICAL_IMPULSE_VIRTUAL_ENV)/bin/activate"
|
||||||
python "$SCRIPT_DIR/generate_colors_material.py" "${generate_colors_material_args[@]}" \
|
python "$SCRIPT_DIR/generate_colors_material.py" "${generate_colors_material_args[@]}" \
|
||||||
> "$STATE_DIR"/user/generated/material_colors.scss
|
> "$STATE_DIR"/user/generated/material_colors.scss
|
||||||
|
|||||||
Reference in New Issue
Block a user