#!/bin/bash -eu # play-clips.sh: FILES=`find "$@" -type f -name '*.mp4' -o -name '*.mkv'` dur=30 while true; do FILE=`echo "$FILES" | shuf | head -n1` len=`fflen "$FILE"` leni=${len%.*} leni_sub_dur=$[ $leni - $dur ] start=$[ $RANDOM % $leni_sub_dur ] # ws=`i3-msg -t get_workspaces | jq '.[] | select(.focused==true).num'` eval `xdotool getmouselocation --shell` v i3-msg 'workspace number 0' # (sleep 1; v i3-msg "workspace number $ws") & (sleep 1; v xdotool mousemove $X $Y) & mp --volume=30 --start=$start --length=$dur --keep-open=no --video-align-x=1 --vf=lavfi=cropdetect "$FILE" done