2019-08-04 01:50:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Shoutout to mitchweaver on gitgub for the script as a useful base for this one
|
|
|
|
# Link to exact script: https://github.com/mitchweaver/bin/blob/master/mpv/mpvbg
|
|
|
|
# There's lots of good scripts in that repository so check them all out
|
|
|
|
|
|
|
|
pkill -9 xwinwrap
|
|
|
|
cacheFile="${HOME}/.cache/mpvbg.pid"
|
|
|
|
base="/home/shockrah/Pictures/VPapes"
|
|
|
|
|
|
|
|
# Pic two random video papes
|
|
|
|
pape1=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
|
|
|
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
2019-09-07 23:20:17 +00:00
|
|
|
echo
|
2019-08-04 01:50:14 +00:00
|
|
|
while "$pape1" = "$pape2"
|
|
|
|
do
|
|
|
|
pape2=`ls "${HOME}/Pictures/VPapes" | shuf | head -n 1`
|
|
|
|
done
|
|
|
|
|
|
|
|
mpv="mpv --wid WID --no-config --keepaspect=no --loop \
|
|
|
|
--no-border --vd-lavc-fast --x11-bypass-compositor=no \
|
|
|
|
--gapless-audio=yes --vo=x11 --hwdec=auto \
|
|
|
|
--x11-name=mpvbg"
|
|
|
|
|
|
|
|
# store our pid here so we can avoid killing our background later
|
|
|
|
# Example: $ kill $(pgrep mpv | grep -v $(pgrep -P $(cat ${HOME}/.cache/mpvbg.pid)))
|
|
|
|
# --- Here we are killing "all mpvs, except with THIS PID"
|
|
|
|
# --- This lets us kill a video we're watching, without stopping our desktop background!
|
|
|
|
|
|
|
|
|
|
|
|
# First monitor
|
|
|
|
xwinwrap -g 1920x1080 -ni -fdt -sh rectangle -un -b -nf -ov -- $mpv "$base/$pape1" & > /dev/null 2>&1 &
|
|
|
|
echo $! > ${HOME}/.cache/mpvbg.pid
|
2019-09-07 23:20:17 +00:00
|
|
|
echo "$pape1" > $HOME/.cache/newbga_img
|
2019-08-26 04:03:36 +00:00
|
|
|
|
|
|
|
# Quick check if we even have a second monitor at all
|
|
|
|
c=`xrandr | grep ' connected' | wc -l`
|
2019-10-20 20:08:45 +00:00
|
|
|
if [ $c = "1" ]
|
2019-08-26 04:03:36 +00:00
|
|
|
then
|
|
|
|
exit
|
2019-10-20 03:33:26 +00:00
|
|
|
else
|
|
|
|
# Second monitor
|
|
|
|
xwinwrap -g 1920x1080+1920+0 -ni -fdt -sh rectangle -un -b -nf -ov -- $mpv "$base/$pape2" & > /dev/null 2>&1 &
|
|
|
|
echo $! >> ${HOME}/.cache/mpvbg.pid
|
|
|
|
echo "$pape1" >> $HOME/.cache/newbga_img
|
2019-08-26 04:03:36 +00:00
|
|
|
fi
|