xscreensaver-aerial
xscreensaver-aerial copied to clipboard
Show same video in consecutive runs
Solves: https://github.com/graysky2/xscreensaver-aerial/issues/6
Goal:
- Show the same video on multiple screens
- Don't change the way how videos are chosen
Last used video is saved to $XDG_CONFIG_HOME/.atv4-previous[-4k]
.
If $XDG_CONFIG_HOME/.atv4-previous[-4k]
was edited during the last 30 seconds then video from the previous run is used.
Otherwise, video is picked as usual.
I'm wondering if date
is available everywhere. Especially the -r
option.
date
is part of coreutils
which is listed as a dependency.
there is a race condition - script is launched for all screens and before any manages to pick the video, the other has already checked the $XDG_CONFIG_HOME/.atv4-previous
. I will fix this.
I'm still getting different images on multiple screens occasionally (about every 30 runs).
Whole thing now works like this:
- wait until there is no lock file or until it gets too old (3s)
- write lock file
- goto 1) if someone have overwritten the lock
- use previous video (and return) if there is fresh enough
$prev_used
file - continue normally
It is still possible that different videos will be picked on multiple screens but the chance is pretty small.
I have tested this on a dual monitor setup and I always didn't get a single case of different videos in about 100 runs.
If the script is killed and the lock is left in place it expires in 3 seconds. So theoretically there could be a 3-second freeze in the following scenario:
- script creates a lock and is killed before picking a video
- script is immediately run again
Second run of the script would wait 3 seconds and then continue normally.
I am currently using this. Thanks for sharing.