Code: Select all
#!/bin/bash
APP="ungoogled-chromium"
FILE="/tmp/$APP.tar.xz"
WORKDIR=$(mktemp -d) || exit 1
# Download latest release if necessary
if [ ! -f "$FILE" ]; then
curl -# -L $(curl -s https://api.github.com/repos/ungoogled-software/ungoogled-chromium-portablelinux/releases/latest | grep "browser_download_url.*tar.xz" | cut -d '"' -f 4) -o "$FILE"
fi
tar -xf "$FILE" -C $WORKDIR
# Prepare APP dir
mkdir -p "$WORKDIR"/{opt,usr/{local/bin,share/{applications,icons/hicolor/48x48/apps}}}
DIR=$(tar -tf "${FILE}" | head -1 | cut -f1 -d"/")
mv "$WORKDIR/$DIR" "$WORKDIR/opt/$APP"
# Create symlinks
echo -e "chrome\nchromium" | xargs -I {} ln -sf /opt/"$APP"/chrome "$WORKDIR"/usr/local/bin/{}
# Create .desktop launcher
cp "$WORKDIR/opt/$APP"/product_logo_48.png "$WORKDIR"/usr/share/icons/hicolor/48x48/apps/ungoogled-chromium.png
cat > "$WORKDIR/usr/share/applications/$APP.desktop" << EOF
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Chromium (ungoogled)
GenericName=Web Browser
Comment=Access the Internet
Exec=chromium %U
StartupNotify=true
Terminal=false
Icon=ungoogled-chromium
Type=Application
Categories=Application;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 new-window]
Name=Open New Window
Exec=chromium %U
[Desktop Action new-private-window]
Name=Open New Incognito Window
Exec=chromium --incognito %U
EOF
sudo chown 0:0 -R "$WORKDIR"
# If everything went fine create module and remove leftovers
if test $? -eq 0 ; then
dir2xzm "$WORKDIR" "$APP-$(date +%Y%m%d).xzm"
echo "Ungoogled Chromium module created in: /tmp/$APP-$(date +%Y%m%d).xzm"
sudo rm "$FILE"
fi