Skip to content

Instantly share code, notes, and snippets.

@Dhertz
Last active March 28, 2023 02:06
Show Gist options
  • Save Dhertz/9dd69eaad092d0c0fe96 to your computer and use it in GitHub Desktop.
Save Dhertz/9dd69eaad092d0c0fe96 to your computer and use it in GitHub Desktop.
Quick overview of how to get Apple's new TV screensavers working on most linux systems.

Using Apple’s Aerial Screensavers on Ubuntu After coming across the [Aerial] (https://github.com/JohnCoates/Aerial) screensavers for Mac, and installing them, I decided that I had had enough of the graphics-demos of my Ubuntu Precise system. I hope to provide a simple guide on how to add them to your setup as well.

First, you need to install xscreensaver (for example with aptitude, but your distro should have it):

sudo aptitude install xscreensaver

and the latest version of mpv (you must use the latest version, see here for a list of repos for various package managers:

sudo add-apt-repository ppa:mc3man/mpv-tests
sudo aptitude update
sudo aptitude install mpv

Then, we need to go and actually get the videos that Apple uses as screensavers. I wanted to do this regularly as they may add more locations or videos, so I wrote a hacky script that checks the server to see if there are any videos that I do not have on disk and download them:

#!/usr/bin/python

import json
import os
import requests
import sys

if len(sys.argv) != 2:
  print("Usage: %s <folder to save videos to>" % (sys.argv[0]))
  sys.exit(1)

downloadDir = sys.argv[1]

if downloadDir[-1] != '/':
  downloadDir += '/'

response = requests.get("http://a1.phobos.apple.com/us/r1000/000/" +
     "Features/atv/AutumnResources/videos/entries.json")

screensavers = json.loads(response.text)
for screensaver in screensavers:
  for asset in screensaver['assets']:
    filename = downloadDir + asset['id'] + ".mov"
    if not os.path.isfile(filename):
      print("Downloading %s" % (asset['url'],))
      film = requests.get(asset['url'], stream=True)
      with open (filename, "wb") as filmFile:
        print("Writing %s to %s" % (asset['id'], filename))
        for chunk in film.iter_content(chunk_size=1024):
          if chunk:
            filmFile.write(chunk)

and then I set it to be run every day at 2:16am by adding this to my crontab (run crontab -e):

16 02 * * * /home/dhertz/screensavers/get_screensavers.py /home/dhertz/screensavers

You will want to replace where you saved the script and the folder where you wish to save the videos as appropriate.

Finally, I added this to my .xscreensaver (which by default is in your home directory - if it is not there start xscreensaver), after all of the other screensaver options (at the end of the big list of names with lines that end with \n\)

 Best:         "Apple Aerial"   mpv --really-quiet --shuffle --no-audio       \
                                  --fs --loop=inf --no-stop-screensaver       \
                                  --wid=$XSCREENSAVER_WINDOW --panscan=1      \
                                  $HOME/screensavers/*                      \n\

and selected "Only One Screen Saver", "Apple Aerial" and to Cycle After 0 minutes in the xscreensaver-demo:

@matthewlswanson
Copy link

matthewlswanson commented Jul 31, 2017

I am having trouble getting it to show in the list of xscreensaver. I installed python-requests, added that script with the download location, ran it and downloaded the videos, edited the .xscreensaver file, and it does not show in the list.

Ubuntu 16.04
xscreensaver 5.37-3
mpv 2:0.26-0

EDIT Also even when I kill all xscreensaver processes and then edit the file, all my changes will be gone when I open it again.

@iamjmat
Copy link

iamjmat commented May 26, 2018

I am having trouble in Fedora 28. I added the entry to .xscreensaver but it is still not showing entry in xscreensaver-demo GUI. Anyone faced this issue ?

Edit: I added the entry again and it showed up now in xscreensaver. But the edits will be gone if I restart my machine.

@peterhatz
Copy link

Works on Pop!_OS beautifully. Remember to change the command line in Settings. If you've downloaded the screensavers to ~Downloads/Apple, change to /usr/bin/mpv --really-quiet --shuffle --no-audio --fs --loop=inf --no-stop-screensaver --wid=$XSCREENSAVER_WINDOW --panscan=1 $HOME/Downloads/Apple/*.mov

@ntassani, the above should help you if you haven't already figured it out :)

@peterhatz
Copy link

Hi! Im getting this error:
xscrensaver: signal:0 child pid 4276 (mpv) exited abnormally (code 2). Any help?
Thanks in advice!

Remember to change the command line in Settings; see my comment just now.

@crxbit
Copy link

crxbit commented Aug 8, 2020

Worked for me using Elementary OS 5.1.6 hera.
Thanks for these scripts!

@iBanJavascript
Copy link

iBanJavascript commented Jan 26, 2022

I've used a combination of instructions/improvements/tips from Dhertz, passcod, advance512, adet4ever, samuelstein & peterhatz to construct the download/update script, the cron job, the xscreensaver settings & the control panel particulars.

Everything works -- except -- the videos don't rotate/shuffle. It just plays the same one over and over until I interrupt it. Then after resuming, it chooses a different video but, once again, plays only that one over and over.

i've had this same result on three different VMWare Fusion virtual machines: Kobachi (Ubuntu bionic), Pop_OS (Ubuntu Impish) and Elementary OS 6.1 Jølnir.

This thread is a bit aged but I was wondering if the configuration of any of the above text files needs to be updated to account for changes in Ubuntu.

Thanks in advance for any insight or tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment