Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show same video in consecutive runs #19

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

curusarn
Copy link

@curusarn curusarn commented Mar 8, 2019

Solves: #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.

@curusarn
Copy link
Author

curusarn commented Mar 8, 2019

date is part of coreutils which is listed as a dependency.

@curusarn
Copy link
Author

curusarn commented Mar 8, 2019

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.

@curusarn
Copy link
Author

curusarn commented Mar 8, 2019

I'm still getting different images on multiple screens occasionally (about every 30 runs).

@curusarn
Copy link
Author

curusarn commented Mar 8, 2019

Whole thing now works like this:

  1. wait until there is no lock file or until it gets too old (3s)
  2. write lock file
  3. goto 1) if someone have overwritten the lock
  4. use previous video (and return) if there is fresh enough $prev_used file
  5. continue normally

@curusarn
Copy link
Author

curusarn commented Mar 8, 2019

It is still possible that different videos will be picked on multiple screens but the chance is pretty small.

@curusarn
Copy link
Author

curusarn commented Mar 8, 2019

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.

@curusarn
Copy link
Author

curusarn commented Mar 8, 2019

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:

  1. script creates a lock and is killed before picking a video
  2. script is immediately run again

Second run of the script would wait 3 seconds and then continue normally.

@graysky2 graysky2 force-pushed the master branch 4 times, most recently from 0daf1fb to 8a73dbb Compare August 11, 2020 12:50
@gmfricke
Copy link

I am currently using this. Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants