mirror of
https://github.com/ublue-os/bazzite.git
synced 2025-01-30 03:32:36 +00:00
149 lines
5.4 KiB
Bash
Executable File
149 lines
5.4 KiB
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
IMAGE_INFO="/usr/share/ublue-os/image-info.json"
|
|
IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO)
|
|
BASE_IMAGE_NAME=$(jq -r '."base-image-name"' < $IMAGE_INFO)
|
|
FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO)
|
|
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
|
|
|
|
# INIT
|
|
BAZZITE_CONFIG_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/bazzite"
|
|
mkdir -p "$BAZZITE_CONFIG_DIR"
|
|
|
|
# SCRIPT VERSION
|
|
USER_SETUP_VER=24
|
|
USER_SETUP_VER_FILE="$BAZZITE_CONFIG_DIR/version"
|
|
USER_SETUP_FEDORA_VER_FILE="$BAZZITE_CONFIG_DIR/fedora_version"
|
|
|
|
if [[ -f "$HOME/.bazzite-configured" ]]; then
|
|
mv -f "$HOME/.bazzite-configured" "$USER_SETUP_VER_FILE"
|
|
fi
|
|
|
|
if [[ -f "$HOME/.bazzite-configured-fedora-version" ]]; then
|
|
mv -f "$HOME/.bazzite-configured-fedora-version" "$USER_SETUP_FEDORA_VER_FILE"
|
|
fi
|
|
|
|
USER_SETUP_VER_RAN=$(cat $USER_SETUP_VER_FILE)
|
|
USER_SETUP_FEDORA_VER_RAN=$(cat $USER_SETUP_FEDORA_VER_FILE)
|
|
|
|
# Run script if updated
|
|
if [[ -f $USER_SETUP_VER_FILE && $USER_SETUP_VER = $USER_SETUP_VER_RAN ]]; then
|
|
if [[ -f $USER_SETUP_FEDORA_VER_FILE && $FEDORA_VERSION = $USER_SETUP_FEDORA_VER_RAN ]]; then
|
|
echo "User setup v$USER_SETUP_VER has already run. Exiting..."
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Enable Flathub
|
|
if grep -qz 'fedora' <<< $(flatpak remotes); then
|
|
flatpak remote-delete --user fedora --force
|
|
fi
|
|
flatpak remote-add --if-not-exists --user flathub /etc/flatpak/remotes.d/flathub.flatpakrepo
|
|
flatpak remote-modify --user --enable flathub
|
|
|
|
# Handle privileged tasks
|
|
pkexec /usr/libexec/bazzite-privileged-user-setup
|
|
|
|
# Set up optional Gradience themes
|
|
THEME_DIR="/usr/share/ublue-os/bazzite/themes"
|
|
GRADIENCE_DIR="$HOME/.var/app/com.github.GradienceTeam.Gradience/config/presets/user"
|
|
mkdir -p "$GRADIENCE_DIR"
|
|
if [[ ! -f "$GRADIENCE_DIR/vapor.json" ]]; then
|
|
cp "$THEME_DIR/vapor.json" "$GRADIENCE_DIR/vapor.json"
|
|
fi
|
|
if [[ ! -f "$GRADIENCE_DIR/vgui2.json" ]]; then
|
|
cp "$THEME_DIR/vgui2.json" "$GRADIENCE_DIR/vgui2.json"
|
|
fi
|
|
|
|
# Initialize Prompt config
|
|
# This is intentionally run on both images to ensure a user rebasing from Silverblue to Kinoite
|
|
# doesn't get their Prompt config wiped out.
|
|
echo 'Configuring Prompt'
|
|
if [[ ! -f "$BAZZITE_CONFIG_DIR/prompt-initialized" ]]; then
|
|
if [[ $BASE_IMAGE_NAME =~ "kinoite" ]]; then
|
|
dconf load / < /etc/dconf/db/local.d/02-bazzite-kde
|
|
fi
|
|
touch "$BAZZITE_CONFIG_DIR/prompt-initialized"
|
|
fi
|
|
|
|
if [[ $BASE_IMAGE_NAME =~ "kinoite" ]]; then
|
|
echo 'Running setup for Kinoite'
|
|
|
|
echo 'Enabling System76-Scheduler KWin script'
|
|
kwriteconfig5 --file kwinrc --group Plugins --key kwin-system76-scheduler-integrationEnabled true
|
|
|
|
if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then
|
|
echo 'Running setup for Kinoite on Steam Deck'
|
|
if [[ ! -f "$HOME/Desktop/Return.desktop" ]]; then
|
|
echo 'Re-creating return to gamemode shortcut'
|
|
mkdir -p $HOME/Desktop/
|
|
cp "/etc/skel/Desktop/Return.desktop" "$HOME/Desktop/Return.desktop"
|
|
fi
|
|
fi
|
|
else
|
|
echo 'Running setup for Silverblue'
|
|
|
|
if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then
|
|
echo 'Running setup for Silverblue on Steam Deck'
|
|
|
|
echo 'Setting up templates'
|
|
mkdir -p "$HOME/Templates"
|
|
if [[ ! -f "$HOME/Templates/vkBasalt.conf" ]]; then
|
|
ln -s "/etc/vkBasalt.conf" "$HOME/Templates/vkBasalt.conf"
|
|
fi
|
|
if [[ ! -f "$HOME/Templates/dxvk.conf" ]]; then
|
|
ln -s "/etc/dxvk-example.conf" "$HOME/Templates/dxvk.conf"
|
|
fi
|
|
|
|
echo 'Tweaking GNOME indexer'
|
|
if [[ ! -f "$HOME/.steam/.trackerignore" ]]; then
|
|
mkdir -p "$HOME/.steam"
|
|
touch "$HOME/.steam/.trackerignore"
|
|
fi
|
|
if [[ ! -f "${XDG_DATA_HOME:-$HOME/.local/share}/Steam/.trackerignore" ]]; then
|
|
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/Steam"
|
|
touch "${XDG_DATA_HOME:-$HOME/.local/share}/Steam/.trackerignore"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Deck Build Setup
|
|
if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then
|
|
# HHD Setup
|
|
if [[ "ROG Ally RC71L_RC71L:83E1:G1618-04:G1617-01:G1619-05:AIR Plus:" =~ ":$SYS_ID:" ]]; then
|
|
echo 'Enabling HHD'
|
|
pkexec /usr/libexec/bazzite-enable-hhd "$USER"
|
|
fi
|
|
|
|
# SDGyroDSU Setup
|
|
if [[ ":Jupiter:Galileo:" =~ ":$SYS_ID:" ]]; then
|
|
systemctl --user enable --now sdgyrodsu.service
|
|
else
|
|
systemctl --user disable --now sdgyrodsu.service
|
|
fi
|
|
|
|
# Legion Rotation Fix
|
|
AUTOSTART_FOLDER=${XDG_CONFIG_HOME:-$HOME/.config}
|
|
|
|
# Remove old legion-only file
|
|
if [[ -f "$AUTOSTART_FOLDER/autostart/bazzite-handle-legion-go-rotation.desktop" ]]; then
|
|
rm -f "$AUTOSTART_FOLDER/autostart/bazzite-handle-legion-go-rotation.desktop"
|
|
fi
|
|
|
|
if [[ ":ROG Ally RC71L_RC71L:83E1:Loki Max:" =~ ":$SYS_ID:" ]] && [[ $BASE_IMAGE_NAME =~ "kinoite" ]]; then
|
|
if [[ ! -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop" ]]; then
|
|
echo 'Adding rotation fix'
|
|
mkdir -p "$AUTOSTART_FOLDER/autostart"
|
|
printf "[Desktop Entry]\nExec=/usr/libexec/bazzite-rotation-fix\nIcon=dialog-scripts\nName=bazzite-rotation-fix\nType=Application\nX-KDE-AutostartScript=true\n" > "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop"
|
|
fi
|
|
elif [[ -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop" ]]; then
|
|
echo 'Non-supported or GNOME detected, removing rotaion fix'
|
|
rm -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop"
|
|
fi
|
|
fi
|
|
|
|
# Prevent future executions
|
|
echo "Writing state file"
|
|
echo $USER_SETUP_VER > $USER_SETUP_VER_FILE
|
|
echo $FEDORA_VERSION > $USER_SETUP_FEDORA_VER_FILE
|