-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaver_mpv2
executable file
·48 lines (45 loc) · 1.81 KB
/
saver_mpv2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
#
# Copyright 2014 Google Inc. All rights reserved.
#
# Modifications by Kane York: LIST_VIDEOS_COMMAND hardcoded to a pair of
# folders based on monitor width.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
: ${XSECURELOCK_LIST_VIDEOS_COMMAND:=find ~/Videos -type f}
: ${XSECURELOCK_LIST_VIDEOS_FILTER:=}
: ${XSECURELOCK_IMAGE_DURATION_SECONDS:=1}
is_widescreen="$(xwininfo -id "${XSCREENSAVER_WINDOW}" | awk '/ Width:/ { width = $2 }; / Height:/ { height = $2 }; END { widescreen = width > height; print widescreen };')"
if test "$is_widescreen" -eq 0; then
XSECURELOCK_LIST_VIDEOS_COMMAND="find ~/Videos/Screensaver-Mobile -type f $XSECURELOCK_LIST_VIDEOS_FILTER"
else
XSECURELOCK_LIST_VIDEOS_COMMAND="find ~/Videos/Screensaver -type f $XSECURELOCK_LIST_VIDEOS_FILTER"
fi
# Run mpv in a loop so we can quickly restart mpv in case it exits (has shown
# the last picture/video).
while true; do
sh -c "$XSECURELOCK_LIST_VIDEOS_COMMAND" | shuf | head -n 256 |\
/usr/bin/mpv \
--no-input-terminal \
--really-quiet \
--no-stop-screensaver \
--wid="${XSCREENSAVER_WINDOW}" \
--no-audio \
--image-display-duration="${XSECURELOCK_IMAGE_DURATION_SECONDS}" \
--shuffle \
--playlist=- &
# Avoid spinning if mpv exits immediately, but don't wait to restart mpv in
# the common case.
sleep 1
wait
done