mirror of
https://github.com/ublue-os/bazzite.git
synced 2025-01-30 03:32:36 +00:00
110 lines
3.4 KiB
Bash
Executable File
110 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
# SCRIPT VERSION
|
|
VER=24
|
|
VER_FILE="/etc/bazzite/flatpak_manager_version"
|
|
VER_RAN=$(cat $VER_FILE)
|
|
IMAGE_INFO="/usr/share/ublue-os/image-info.json"
|
|
IMAGE_FLAVOR=$(jq -r '."image-flavor"' < $IMAGE_INFO)
|
|
BASE_IMAGE_NAME=$(jq -r '."base-image-name"' < $IMAGE_INFO)
|
|
|
|
# IMAGE IDENTIFIERS
|
|
KNOWN_IMAGE_FLAVOR_FILE="/etc/bazzite/flatpak_manager_image_flavor"
|
|
KNOWN_IMAGE_FLAVOR=$(cat $KNOWN_IMAGE_FLAVOR_FILE)
|
|
|
|
# Run script if updated
|
|
if [[ -f $VER_FILE && $VER = $VER_RAN ]]; then
|
|
if [[ -f $KNOWN_IMAGE_FLAVOR_FILE ]]; then
|
|
if [[ $IMAGE_FLAVOR = $KNOWN_IMAGE_FLAVOR ]]; then
|
|
echo "Flatpak manager v$VER has already ran. Exiting..."
|
|
exit 0
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Ensure Flathub is enabled
|
|
flatpak remote-add --if-not-exists --system flathub /etc/flatpak/remotes.d/flathub.flatpakrepo
|
|
flatpak remote-modify --system --enable flathub
|
|
|
|
PROTONTRICKS_SETUP_FILE="/etc/bazzite/protontricks_installed"
|
|
if [[ ! -f "$PROTONTRICKS_SETUP_FILE" ]]; then
|
|
if ! grep -q "com.github.Matoking.protontricks" <<< $(/usr/bin/flatpak list --app --columns=application); then
|
|
flatpak install --system --assumeyes com.github.Matoking.protontricks
|
|
touch "$PROTONTRICKS_SETUP_FILE"
|
|
else
|
|
touch "$PROTONTRICKS_SETUP_FILE"
|
|
fi
|
|
fi
|
|
|
|
# Flatpak theming support
|
|
flatpak override \
|
|
--filesystem=xdg-config/gtk-4.0:ro \
|
|
--filesystem=xdg-config/gtk-3.0:ro \
|
|
--filesystem=xdg-data/icons:ro
|
|
|
|
# XInput for Firefox
|
|
flatpak override \
|
|
--system \
|
|
--env=MOZ_USE_XINPUT2=1 \
|
|
org.mozilla.firefox
|
|
|
|
# Fix printing on LibreOffice
|
|
flatpak override \
|
|
--system \
|
|
--socket=cups \
|
|
--socket=session-bus \
|
|
org.libreoffice.LibreOffice
|
|
|
|
# Allow MangoHUD config for Flatpaks
|
|
flatpak override \
|
|
--filesystem=xdg-config/MangoHud:ro \
|
|
--filesystem=xdg-config/vkBasalt:ro
|
|
|
|
# Fix permissions for XIV Launcher
|
|
flatpak override \
|
|
--device=dri \
|
|
dev.goats.xivlauncher
|
|
|
|
# Fix permissions for Protontricks
|
|
flatpak override \
|
|
--filesystem=~/.local/share/Steam \
|
|
--filesystem=/var/mnt \
|
|
--filesystem=/run/media \
|
|
com.github.Matoking.protontricks
|
|
|
|
# Params needed for HW accelerated video on Nvidia (Ignoring hybrid systems)
|
|
if [[ $IMAGE_FLAVOR =~ "nvidia" ]] && [ $(grep -o "\-display" <<< $(lshw -C display) | wc -l) -le 1 ] && grep -q "vendor: NVIDIA Corporation" <<< $(lshw -C display); then
|
|
flatpak override \
|
|
--system \
|
|
--filesystem=host-os \
|
|
--env=LIBVA_DRIVER_NAME=nvidia \
|
|
--env=LIBVA_DRIVERS_PATH=/run/host/usr/lib64/dri \
|
|
--env=LIBVA_MESSAGING_LEVEL=1 \
|
|
--env=MOZ_DISABLE_RDD_SANDBOX=1 \
|
|
--env=NVD_BACKEND=direct \
|
|
org.mozilla.firefox
|
|
else
|
|
# Undo if user was previously using a Nvidia image and is no longer
|
|
flatpak override \
|
|
--system \
|
|
--nofilesystem=host-os \
|
|
--unset-env=LIBVA_DRIVER_NAME \
|
|
--unset-env=LIBVA_DRIVERS_PATH \
|
|
--unset-env=LIBVA_MESSAGING_LEVEL \
|
|
--unset-env=MOZ_DISABLE_RDD_SANDBOX \
|
|
--unset-env=NVD_BACKEND \
|
|
org.mozilla.firefox
|
|
fi
|
|
|
|
# Set up Firefox default configuration
|
|
mkdir -p /var/lib/flatpak/extension/org.mozilla.firefox.systemconfig/x86_64/stable/defaults/pref
|
|
rm -f /var/lib/flatpak/extension/org.mozilla.firefox.systemconfig/x86_64/stable/defaults/pref/*bazzite*.js
|
|
/usr/bin/cp -rf /usr/share/ublue-os/firefox-config/* /var/lib/flatpak/extension/org.mozilla.firefox.systemconfig/x86_64/stable/defaults/pref/
|
|
|
|
# Update Flatpaks
|
|
flatpak --system update -y
|
|
|
|
mkdir -p /etc/bazzite
|
|
echo $VER > $VER_FILE
|
|
echo $IMAGE_FLAVOR > $KNOWN_IMAGE_FLAVOR_FILE
|