-


Video Livestream Wallpaper For Your GNOME, Xfce Or bspwm Desktop

Livestream wallpaper Linux

This article explains how to use a livestream as a desktop wallpaper on GNOME, Xfce or bspwm with X11 (it does not work with Wayland). The live video stream can be any stream you like (a live city cam or the ISS live feed for example), as long as it's supported by Streamlink.

It's important to note that you'll lose the desktop icons functionality by using this livestream wallpaper. That's because the desktop icons will be shown behind the livestream video wallpaper. This is the case with Xfce, and both GNOME desktops in which Nautilus draws the desktop, and using the Desktop Icons GNOME Shell extension. This is not an issue if you use multiple monitors, as you could have your desktop icons on a different monitor than the livestream video wallpaper.

You're probably thinking this uses a lot of CPU. On my Ubuntu 19.04 desktop, with mpv set to use hardware-accelerated video decoding, an 1080p live video feed used as my desktop wallpaper only uses around 2-3% CPU according to htop (so 2-3% of a single core), so it's basically negligible. Without hardware video decoding though, mpv used between 30 and 35% according to htop, so yes, that's a bit too much. So make sure you use mpv with hardware acceleration for this.

This is a short video showing the livestream wallpaper on my Ubuntu 19.04 (GNOME) desktop, using a live video feed of New York:


What you'll need:

  • Use GNOME, Xfce or bspwm with X11 (other desktops might work, but in my tries it didn't work as it should with KDE Plasma or MATE; I didn't try others)
  • A live video stream, be it a YouTube video livestream, an ISS live feed, some city live webcam, and so on
  • Streamlink to extract the stream and play it with mpv
  • mpv 0.29.1 or newer to play the livestream video (it might work with some older versions, but while testing this with mpv 0.27.2, the window borders did not disappear, so in case you run into this issue, you probably need a newer mpv version)
  • Xwinwrap fork (the link points to a fork of Xwinwrap with some enhancements, other versions might not work correctly), which is needed to stick mpv to the desktop background

These are a few live video feed examples you could use as your GNOME or bspwm desktop wallpaper:


Related: Embed An Audio Visualizer On Your Linux Desktop Background Using GLava (PPA Installation And Configuration Guide)

Install the programs needed to use a live video feed as a desktop wallpaper


1. Install mpv

- Debian buster & sid / Ubuntu 19.04 (due to needing the latest mpv; for a PPA for Ubuntu 18.04 see a bit down below):

sudo apt install mpv

- Fedora:

Enable the RPMFusion repository if you haven't already:

sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm

sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

And install mpv:

sudo dnf install mpv jack-audio-connection-kit

I added jack-audio-connection-kit to the mpv installation command because mpv does not depend on this package in Fedora 30, and yet it fails to start without it (showing an error: mpv: error while loading shared libraries: libjack.so.0: cannot open shared object file: No such file or directory).

- Arch Linux:

sudo pacman -S mpv

Like I mentioned near the top of the article, you'll most probably need mpv 0.29.1 or newer. It might work with some older versions, but while testing this with mpv 0.27.2, the window borders did not disappear, so in case you run into this issue, you probably need a newer mpv version. Ubuntu 19.04 has mpv 0.29.1, and for older Ubuntu versions, like Ubuntu 18.04 you can use a PPA.

2. Install Xwinwrap

- Ubuntu / Debian: you can find step by step installation instructions (from source) on the Xwinwrap fork GitHub project homepage. There's also a DEB package available here (it works on newer Ubuntu versions, including Ubuntu 18.04 and 19.04).

- Arch Linux: there is an AUR package for Xwinwrap (fork)

If you use some other Linux distribution you'll need to figure out what dependencies you need to install from the package names listed for Debian / Ubuntu on the Xwinwrap GitHub project page, and then compile it using the instructions from there.

3. Install Streamlink

- Debian / Ubuntu:

sudo apt install streamlink

- Fedora:

sudo dnf install python3-streamlink

- Arch Linux:

sudo pacman -S streamlink

On other Linux distributions see the Streamlink installation page.

On Ubuntu 18.04 (and older), Streamlink may be too old to play some streams. For example on my Ubuntu 18.04 laptop it failed to play a YouTube stream. In this case, you can download a newer Streamlink from Ubuntu 19.04 which works in older Ubuntu versions (at least in Ubuntu 18.04). You'll need to download and install 2 packages (click any mirror on that page to download the DEB):


If you're installing the DEB packages using a GUI, start with python3-streamlink, and then install the streamlink DEB package.

Wallpaper related: How To Set A Different Background For Each Monitor On Gnome

Create the 2 scripts needed to use a livestream as your wallpaper


As a reminder, using this requires running Xorg. Fedora for example uses Wayland by default, so if you want to use this on Fedora, logout and from the login screen choose Gnome on Xorg, then login.

1. Create 2 scripts which are going to be used to fetch the livestream and set it as your desktop background.

To use a livestream of your choice as a desktop background you need to create 2 scripts. Create 2 files, called livebackground.sh and livestream.sh in a folder named scripts in your home directory (so the scripts paths are ~/scripts/livebackground.sh and ~/scripts/livestream.sh). You can use other paths and script names, but you'll need to replace any mention of the scripts from my instructions with your custom names and paths!

Related: How To Embed A Google Calendar Widget On Your Linux Desktop Background

Add the following to the livebackground.sh script, save the file:

#!/usr/bin/env sh
xwinwrap -fs -fdt -ni -b -nf -- ~/scripts/livestream.sh WID

This is what each Xwinwrap option used in this code means:

  • -fs: full screen
  • -fdt: foce WID window a desktop type window
  • -ni: ignore input (so the player controls don't appear on mouse over, etc.)
  • -b: below (so the livestream window is shown below other windows)
  • -nf: no focus

Those wanting to specify the resolution, remove -fs (full screen) and add -g WxH (W=width, H=height) instead, for example -g 1920x1080.

If you use two monitors, you'll need to specify the complete geometry: replace -fs with -g WxH+X+Y (W=width, H=height, X=x coordinates, Y=y coordinates). As an example, if you have two monitors, both using 1920x1080 screen resolutions, and you want to show the livestream wallpaper on the second monitor (the one on the right), use: -g 1920x1080+1920+0. Another example: if the monitor on the left uses a 2560x1080 screen resolution, and the one on the right uses 1920x1080, and you want the livestream wallpaper to show on the monitor on the right, use -g 1920x1080+2560+0.

These options were enough to get a livestream background on my Ubuntu 19.04 Gnome desktop, but in case you're running into issues, there are a few more options you can use, which you can find on the Xwinwrap page.

In the livestream.sh script use this code and save the file:

#!/usr/bin/env sh
streamlink -p "mpv --no-audio --wid=$1" https://www.youtube.com/watch?v=-M8u4jaCCJs best

In this script I'm using an Amsterdam live video feed from YouTube, but you can use any livestream you wish, as long as it's supported by Streamlink. All you have to do is replace the YouTube link in this script with the live video feed you want to use. I would have liked to use the ISS Earth View cam as my example, but it's black when the International Space Station is on the night side of the Earth, so you might have thought that it's not working if testing it when it's black.

Also, best after the URL means to use the best available quality. You can run streamlink URL to see all available qualities.

It's very important to mention that mpv supports hardware decoding so it can have a very low CPU usage. See this and this link for info.

As an example, with the required packages installed, you can enable VA-API hardware video decoding using --hwdec=vaapi --vo=vaapi (so the streamlink line in the script becomes streamlink -p "mpv hwdec=vaapi --vo=vaapi --no-audio --wid=$1" https://www.youtube.com/watch?v=-M8u4jaCCJs best), or VDPAU using --hwdec=vdpau --vo=vdpau.

2. Make the scripts executable

chmod +x ~/scripts/livestream.sh
chmod +x ~/scripts/livebackground.sh

3. Set a livestream as your wallpaper

Now it's time to set a livestream as you wallpaper. To change your desktop background to a livestream video you need to run the livebackground.sh script - open a terminal and run it:

~/scripts/livebackground.sh

4. Optionally run the livestream wallpaper on startup

If your desktop has an option to add a script to startup (like the Startup Applications app in Ubuntu), use it to add sh -c "~/live-background.sh" (enter this in the Command box) so it runs after you login.

If you don't have a GUI to add startup applications and scripts, you can add it to startup manually, by creating a file called livestream-wallpaper.desktop in ~/.config/autostart/ (create this folder if it doesn't already exist) with the following contents:

[Desktop Entry]
Type=Application
Exec=sh -c "~/scripts/livebackground.sh"
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Livestream wallpaper

Remove the ~/.config/autostart/livestream-wallpaper.desktop file if you no longer want to have the livestream wallpaper automatically start when you login.


Idea & the two scripts via Reddit (r/unixporn - special thanks to u/lukedoomer and u/Invayder)