Skip to content
Snippets Groups Projects
Verified Commit 5448a011 authored by Andreas Gerlach's avatar Andreas Gerlach
Browse files

[sway] add chromium widevine scripts based on systemd-spawn

parent 9b47bdd4
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
set -e
CONTAINER_DIR=/var/lib/machines/
CONTAINER_ID=chromium_widevine
TEMP_DIR="$(mktemp -p /var/cache/ -td ChromeOS-IMG.XXXXXX)"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# check for command availability
available () {
command -v "$1" >/dev/null 2>&1
}
if ! available debootstrap; then
pacman -S debian-archive-keyring debootstrap
fi
if ! available xhost; then
pacman -S xorg-xhost
fi
if ! available curl; then
pacman -S curl
fi
if ! available git; then
pacman -S git
fi
if [ ! -d $CONTAINER_DIR ]; then
echo Creating base directory for systemd containers $CONTAINER_DIR...
mkdir -p $CONTAINER_DIR
fi
if [ ! -d $CONTAINER_DIR/$CONTAINER_ID ]; then
echo Bootstrap new Debian 10 Buster armhf container
cd $CONTAINER_DIR
debootstrap --include=systemd-container,debconf --components=main,universe --arch=armhf buster $CONTAINER_ID
fi
echo "Cloning docker-chromium-armhf from Git repo..."
git clone --progress https://github.com/spikerguy/docker-chromium-armhf/ $TEMP_DIR
echo "Downloading ChromeOS image..."
CHROMEOS_URL="$(curl -s https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf | grep -A11 CB5-312T | sed -n 's/^url=//p')"
CHROMEOS_IMG="$(basename "$CHROMEOS_URL" .zip)"
curl -L "$CHROMEOS_URL" | zcat > "$TEMP_DIR/$CHROMEOS_IMG"
# Note the next free loop device in a variable
echo "Mounting ChromeOS image..."
LOOPD="$(losetup -f)"
mkdir -p $TEMP_DIR/img
losetup -Pf "$TEMP_DIR/$CHROMEOS_IMG"
mount -o ro "${LOOPD}p3" "$TEMP_DIR/img"
echo Setting up environment in systemd container $CONTAINER_ID
systemd-nspawn --directory="$CONTAINER_DIR/$CONTAINER_ID" --bind-ro=$TEMP_DIR:/tmp/chromium --pipe /bin/bash <<'EOF'
echo Installing required dependencies...
apt install --yes --no-install-recommends \
fontconfig fontconfig-config fonts-dejavu-core gconf-service gconf2-common \
libasn1-8-heimdal libasound2 libasound2-data libatk1.0-0 libatk1.0-data libavahi-client3 libavahi-common-data \
libavahi-common3 libcairo2 libcups2 libdatrie1 libdbus-1-3 libdbus-glib-1-2 libexpat1 libfontconfig1 \
libfreetype6 libgconf-2-4 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgmp10 \
libgnutls30 libgraphite2-3 libgssapi-krb5-2 libgssapi3-heimdal libgtk2.0-0 \
libgtk2.0-common libharfbuzz0b libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 \
libhx509-5-heimdal libjbig0 libk5crypto3 libkeyutils1 \
libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libnettle6 libnspr4 libnss3 \
libp11-kit0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpixman-1-0 libpng16-16 libroken18-heimdal \
libsasl2-2 libsasl2-modules-db libsqlite3-0 libtasn1-6 libthai-data libthai0 libtiff5 libwind0-heimdal libx11-6 \
libx11-data libxau6 libxcb-render0 libxcb-shm0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 \
libxext6 libxfixes3 libxi6 libxinerama1 libxml2 libxrandr2 libxrender1 libxss1 libxtst6 shared-mime-info ucf \
x11-common xdg-utils libpulse0 pulseaudio-utils wget libatk-bridge2.0-0 libatspi2.0-0 libgtk-3-0 \
mesa-va-drivers mesa-vdpau-drivers mesa-utils libosmesa6 libegl1-mesa libwayland-egl1-mesa libgl1-mesa-dri
echo "Installing latest supported Chromium version..."
apt install /tmp/chromium/dependencies/chromium*.deb
echo "Moving files into place..."
cp -R /tmp/chromium/img/opt/google/chrome/libwidevinecdm.so /usr/lib/chromium-browser
cp -R /tmp/chromium/img/opt/google/chrome/pepper /usr/lib/chromium-browser
cp -R /tmp/chromium/widevine/netflix-1080p-1.20.1 /usr/lib/chromium-browser/netflix-1080p
echo Adding chromium user...
useradd -m -s /bin/bash chromium
gpasswd -a chromium audio
EOF
echo Cleaning up...
umount "$TEMP_DIR/img"
losetup -d "$LOOPD"
rmdir "$TEMP_DIR"
#!/bin/sh
CONTAINER_DIR=/var/lib/machines/
CONTAINER_ID=chromium_widevine
machinectl -q image-status $CONTAINER_ID >/dev/null 2>&1
IMAGE_STATUS=$?
if [ $IMAGE_STATUS -ne 0 ]; then
echo Please run the install_chromium_widevine script first!
exit 1
fi
if [ ! -d $HOME/.local/share/chromium_widevine ]; then
mkdir -p $HOME/.local/share/chromium_widevine
fi
set -e
# dbus session sharing
if [[ -n $DBUS_SESSION_BUS_ADDRESS ]]; then # remove prefix
host_dbus=${DBUS_SESSION_BUS_ADDRESS#unix:path=};
else # default guess
host_dbus=/run/user/$UID/bus;
fi
# pulse audio access
if [[ -n $PULSE_SERVER ]]; then # remove prefix
host_pulseaudio=${PULSE_SERVER#unix:};
else # default guess
host_pulseaudio=/run/user/$UID/pulse;
fi
xhost +local:
pkexec systemd-nspawn --directory $CONTAINER_DIR/$CONTAINER_ID \
--bind-ro=/tmp/.X11-unix \
--setenv=DISPLAY=$DISPLAY \
--setenv=PULSE_SERVER=unix:/run/user/host/pulse/native \
--setenv=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/host/bus \
--bind-ro=$host_pulseaudio:/run/user/host/pulse \
--bind-ro=$host_dbus:/run/user/host/bus \
--bind-ro=/usr/share/themes/:$XDG_DATA_HOME/themes/ \
--bind=/dev/dri \
--bind=/dev/shm \
--bind=$HOME/.local/share/chromium_widevine:/home/chromium \
--user chromium \
--as-pid2 /usr/bin/chromium-browser "--user-agent='Mozilla/5.0 (X11; CrOS armv7l 12607.82.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.123 Safari/537.36'"
[Desktop Entry]
Type=Application
Encoding=UTF-8
Version=1.0
Name=Chromium Widevine
GenericName=Web Browser
Categories=Network;WebBrowser;
Comment=Browser for Netflix, Amazon and Spotify
Exec=/usr/local/bin/launch_chromium_widevine.sh
Icon=/usr/share/icons/chromium.png
overlays/sway/usr/share/icons/chromium.png

23.3 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment