Borderless Netflix and YouTube windows on Ubuntu

This post shows two lua scripts to set a specific window size and get rid of the window decorations for youtube and netflix. As an extra I will also include the configurations I use for my terminal.

To perform the tasks described above we are going to use Devilspie2. Devilspie2 is a scripting tool that allows to manipulate the windows, changing the size, the window decoration and the position using Lua scripts.

Installation

To install Devilspie2 is straightforward either from the package manager or a terminal:

sudo apt-get install devilspie2

Creating the lua scripts

Devilspie2 works using lua scripts, you can read a full list of the supported functions on their manual. We are going to use just 4 of them.

First, for the netflix window, create a script called netflix.lua in .config/devilspie2/ containing this:

if (get_window_name()=="Netflix") then
    undecorate_window();
    -- x position, y position, x width, y width
    set_window_geometry(1200, 0, 725, 428);
    -- show netflix on every desktop
    pin_window();
end

The last option pin_window() is not working on Unity, but it works with Pantheon, KDE and Gnome. If you run devilspie2 and then open netflix it wont work, because the website has to load before it sets the window name, but the script picks the name right after the application is opened. We will fix that in the next section.

For YouTube this is my youtube.lua file, again it is located in .config/devislpie2/:

if (get_window_name()=="YouTube") then
    undecorate_window();
    -- width, height
    set_window_size(866, 544);
    -- show youtube on every desktop
    pin_window();
end

In this case instead of defining the whole window geometry I just set the window size. Again, some extra tweaking is needed for this to work.

Launching Netflix and YouTube on Chrome

To open Netflix I created the following shell script called netflix in my bin/ folder:

#!/bin/bash

google-chrome --app=https://www.netflix.com

ps cax | grep "devilspie2" > /dev/null
if [ $? -eq 0 ]; then
    killall "devilspie2"
fi

sleep 6s
$(devilspie2)

It opens netflix in app mode and checks if devilspie2 is running. If it is it kills the process, afterwards it waits 6 seconds to give time for the website to load then it runs devilspie2.

Likewise, this is my youtube script to launch YouTube:

#!/bin/bash

google-chrome --app=https://www.youtube.com

ps cax | grep "devilspie2" > /dev/null
if [ $? -eq 0 ]; then
    killall "devilspie2"
fi

sleep 6s
$(devilspie2)

To make things easier you can create a launcher on your desktop or the Unity desktop launcher. This is how it looks on my computer:

../../../_images/desktop.jpg

Lua script for the Terminal

For my terminal I just change the geometry so it uses up all the vertical space and is wide enough for 80 characters to fit when I’m editing files on vim. This is what my terminal.lua script looks like:

if (get_application_name()=="Terminal") then
    set_window_size(768, 1056);
end