1
0
Fork 0
dotfiles/files/.local/bin/wallpaper

31 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2018-05-17 14:25:00 +00:00
# Animated wallpaper
# quick and dirty script, but it works
wallpaper_source="https://massaki.ca/extra/wallpaper.mp4"
wallpaper_static="$HOME/.local/share/wallpaper.png"
wallpaper_anim="$HOME/.local/share/wallpaper.mp4"
if [ ! -f "$wallpaper_anim" ]; then
# calculate screen geometry
screen_size="$(xrandr --screen 0 | grep '^Screen' | grep -Eo 'current [0-9]+ x [0-9]+' | sed -E 's/current ([0-9]+) x ([0-9]+)/\1 \2/g')"
set -- $screen_size
2018-05-17 16:30:04 +00:00
# download, crop and scale
ffmpeg -i "$wallpaper_source" -vf "scale=w=$1:h=$2:force_original_aspect_ratio=increase, crop=w=$1:h=$2:y=(in_w-out_w)" -sws_flags lanczos \
-c:v libx264 -tune fastdecode -preset ultrafast -crf 18 -r 15 "$wallpaper_anim"
2018-05-17 14:25:00 +00:00
# extract static image
ffmpeg -i "$wallpaper_anim" -vframes 1 "$wallpaper_static"
# set static wallpaper
2018-05-17 16:30:04 +00:00
feh --bg-fill --no-xinerama "$wallpaper_static"
2018-05-17 14:25:00 +00:00
fi
if ! acpi --ac-adapter 2>/dev/null | grep -q 'off-line'; then
exec "$HOME/.local/bin/mpv-bg" --really-quiet \
2018-05-17 16:30:04 +00:00
--no-config --no-border --no-audio --vd-lavc-fast \
2018-05-17 14:25:00 +00:00
--loop --panscan=1.0 --scale=oversample --cache-file=TMP "$wallpaper_anim"
fi