Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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:

@zatricky
Copy link

zatricky commented Nov 20, 2015

Worked for me using ArchLinux.

One caveat I came across: Make sure the Screensaver GUI isn't running when you edit .xscreensaver as it will revert your changes. ;)

@samuelstein
Copy link

samuelstein commented Dec 3, 2015

For Ubuntu (tested with 15.04) it's a little bit different. I had to add
"Apple Aerial" mpv --really-quiet --shuffle --no-audio \ --fs --loop=inf --no-stop-screensaver \ --wid=$XSCREENSAVER_WINDOW --panscan=1 \ $HOME/screensavers/* \n\
to the programs section of .xscreensaver file

@passcod
Copy link

passcod commented Jan 21, 2016

Using httpie (but cURL would work fine), jq, and aria2, here's a more efficient, faster (it will happily saturate your network connection), and less hacky version of the download script, which also checks if the video files have been updated, not just if they exist:

#!/usr/bin/bash

url='http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/entries.json'

http $url \
  | jq -r '.[].assets[].url' \
  > .aria.urls

aria2c -x10 -i .aria.urls \
  --auto-file-renaming=false \
  --conditional-get=true \
  --allow-overwrite=true \
  --save-session=.aria.session \
  --force-save=true

The only thing is it creates a bunch of metadata files, so you'll also need to modify the xscreensaver section to use $HOME/path/to/aerial/videos/*.mov ← emphasis on the *.mov.

@Dhertz
Copy link
Author

Dhertz commented Feb 3, 2016

@passcod thanks for rewriting that - I got to learn about some neat new utils as well

@leoherzog
Copy link

leoherzog commented Feb 11, 2016

Thanks for these scripts!

Isn't 02 16 * * * translated to min hour day month weekday?

I think that 02 16 * * * doesn't mean 2:16am every day like you say, but instead 4:02pm every day. :)

@advance512
Copy link

advance512 commented Feb 17, 2016

Yes, it should be 16 02 * * *.

Just to make things a bit clearer.

  • Before executing:
    sudo aptitude install mpv
    make sure to do:
    sudo apt-get update
  • When you edit .xscreensaver, make sure you edit it from something like:
.
.
.
- GL:                           quasicrystal -root                          \n\
- GL:                           unknownpleasures -root                      \n\
- GL:                           projectiveplane -root                       \n\
                                tessellimage -root                          \n\
- GL:                           winduprobot -root                           \n\

to

- GL:                           quasicrystal -root                          \n\
- GL:                           unknownpleasures -root                      \n\
- GL:                           projectiveplane -root                       \n\
                                tessellimage -root                          \n\
- GL:                           winduprobot -root                           \n\
- Best:         "Apple Aerial"  mpv --really-quiet --shuffle --no-audio       \
                                  --fs --loop=inf --no-stop-screensaver       \
                                  --wid=$XSCREENSAVER_WINDOW --panscan=1      \
                                  $HOME/screensavers/*.mov                 \n\

Also, make sure the ~/.xscreensaver file already exists - run the Screensaver control panel at least once. And don't get confused with the apple2 screensaver which isn't related :)

  • Also, for @passcod's trick, make sure you:
    sudo apt-get install jq aria2 httpie
    first, put his bash script in ~/screensavers,
    chmod +x
    it, and also, you can change the first line to:
    #!/bin/bash
    if you get a "bad interpreter" error.

@advance512
Copy link

advance512 commented Feb 17, 2016

Also, @Dhertz, thanks a lot! Awesome!

@Dhertz
Copy link
Author

Dhertz commented Feb 26, 2016

D'oh! I updated the cron to be correct - thanks @xd1936 and @advance512!

I also added the update command and that you might need to start xscreensaver if ~/.xscreensaver is not present (thanks again @advance512)

@gcsecsey
Copy link

gcsecsey commented Jun 20, 2016

Thanks a lot for the turorial, it is awesome! :)

I wanted to use the videos as wallpaper instead of screensavers, so I tweaked it a little bit. Instead of xscreensaver I downloaded xwinwrap, which is for snapping anything to your desktop as wallpaper, and then made this script in the folder of the downloaded videos:

!#/bin/bash 
if ps -e | grep xwinwrap
 then
  killall xwinwrap
  sleep 1
  exit
 fi
xwinwrap -ni -o 1.0 -fs -s -st -sp -b -nf -g 1920x1080+0+0 -- mplayer -wid WID -nosound -shuffle *.mov then
fi
sleep 1
exit

It just kills any instance of xwinwrap running if there's any, or starts an instance when none is running, which can be customized with these flags. Within xwinwrap, mplayer is taking care of the playback.
And as a last step, I added the above script to my crontab so that it starts when I log in (I'm not sure whether it's the best way, but it does the job well):

@reboot ~/hatter/go.sh

I'm running elementary OS, and the result looks something like this (moving... :D):
kepernyokep 2016-06-20 20 06 03
kepernyokep 2016-06-20 20 05 14
kepernyokep 2016-06-20 20 04 02

I'm unsure about resource usage though, it is yet to be tried out. Be careful with unplugged laptops! :D

@ntassani
Copy link

ntassani commented Nov 21, 2016

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

@i-am-angus
Copy link

i-am-angus commented Mar 14, 2017

Thanks for this @Dhertz

Any idea how to play the same clip on multiple monitors while still shuffling through them?

@adet4ever
Copy link

adet4ever commented May 16, 2017

for ubuntu, if you don't have pip installed the script wont run, as it imports requests which doesnt ship with python on ubuntu

https://pypi.python.org/pypi/requests
$ sudo apt install python-pip
$ pip install requests

also remember to give the right execution permission for script file
chmod a+x aeriel.py

@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

peterhatz commented Jun 26, 2019

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

peterhatz commented Jun 26, 2019

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!

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