widevine working with google chrome in a ubuntu jail
i also pass in the DBUS_SESSION_BUS_ADDRESS from the host to the jail in a script
this enables desktop notifications with chrome and also lets you use mpris to control the video in the browser using playerctl
i changed your code to use wayland instead of X11
google-chrome install from your post
as root in the jail
Code:
curl -s https://dl.google.com/linux/linux_signing_key.pub | apt-key --keyring /etc/apt/trusted.gpg.d/google-chrome-stable.gpg add -
printf "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
apt update
apt install google-chrome-stable
google-chrome.desktop location on freebsd
Code:
~/.local/share/applications/google-chrome.desktop
google-chrome.desktop entry runs the wrapper-freebsd script
which in turn runs the wrapper-linux script in the jail
Code:
[Desktop Entry]
Version=1.0
Name=google-chrome
Comment=Browse the World Wide Web
Exec=sh -c 'wrapper-freebsd -a "'"google-chrome --in-process-gpu --disable-direct-composition --disable-gpu --no-sandbox --no-zygote --test-type --enable-features=UseOzonePlatform --ozone-platform=wayland --v=0 "$@" || true %U"'"'
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
StartupNotify=true
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;
Actions=new-window;new-private-window;
[Desktop Action NewWindow]
Name=Open a New Window
Exec=/usr/bin/google-chrome-stable
Exec=firefox -new-window
[Desktop Action NewPrivateWindow]
Name=Open a New Private Window
Exec=/usr/bin/google-chrome-stable --incognito
wrapper-freebsd script
Code:
#!/bin/sh
# wrapper-freebsd
#===============================================================================
# script usage
#===============================================================================
usage () {
# if argument passed to function echo it
[ -z "${1}" ] || echo "! ${1}"
# display help
echo "\
# script usage
$(basename "$0") -u ${USER}"
exit 2
}
#===============================================================================
# check the number of arguments passed to the script
#===============================================================================
[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}"
#===============================================================================
# getopts check the options passed to the script
#===============================================================================
while getopts ':a:h' opt
do
case ${opt} in
a) app="${OPTARG}";;
h) usage;;
\?) usage "${INVALID_OPT_ERR} ${OPTARG}" 1>&2;;
:) usage "${INVALID_OPT_ERR} ${OPTARG} ${REQ_ARG_ERR}" 1>&2;;
esac
done
shift $((OPTIND-1))
#===============================================================================
# run the application in the jail
#===============================================================================
# start pulseaudio
pulseaudio --start --daemonize 2>/dev/null
# doas jexec into ubuntu and run the wrapper script to start the application
doas jexec ubuntu /usr/local/bin/wrapper-linux \
-u "${USER}" \
-d "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" \
-a "${app}"
wrapper-linux script in the ubuntu jail location
Code:
/usr/local/bin/wrapper-linux
wrapper-linux
Code:
#!/bin/bash
#===============================================================================
# wrapper-linux
#===============================================================================
#===============================================================================
# script usage
#===============================================================================
usage () {
# if argument passed to function echo it
[ -z "${1}" ] || echo "! ${1}"
# display help
echo "\
# script usage
$(basename "$0") -u ${USER}"
exit 2
}
#===============================================================================
# check the number of arguments passed to the script
#===============================================================================
[ $# -gt 0 ] || usage "${WRONG_ARGS_ERR}"
#===============================================================================
# getopts check the options passed to the script
#===============================================================================
while getopts ':u:d:a:h' opt
do
case ${opt} in
u) username="${OPTARG}";;
d) dbus="${OPTARG}";;
a) app="${OPTARG}";;
h) usage;;
\?) usage "${INVALID_OPT_ERR} ${OPTARG}" 1>&2;;
:) usage "${INVALID_OPT_ERR} ${OPTARG} ${REQ_ARG_ERR}" 1>&2;;
esac
done
shift $((OPTIND-1))
#===============================================================================
# switch to our user in the jail and start the application
#===============================================================================
su "${username}" -c "${dbus} ${app}" 2>/dev/null
ill have a play around with the chrome flags and jail settings
itv playing drm video using widevine on google-chrome
View attachment 18925