Start using Flatpaks as the main install method for any desktop apps

This commit is contained in:
Josh.5
2023-07-08 02:59:43 +12:00
committed by Josh Sunnex
parent df9423ccad
commit fc700e2200
21 changed files with 224 additions and 477 deletions

View File

@@ -70,10 +70,7 @@ mkdir -p ${XDG_RUNTIME_DIR}
chown -R ${PUID}:${PGID} ${XDG_RUNTIME_DIR}
# Ensure only the 'default' user can access this directory
chmod 700 ${XDG_RUNTIME_DIR}
export XDG_DATA_DIRS="${XDG_DATA_DIRS}:/var/lib/flatpak/exports/share:/home/${USER}/.local/share/flatpak/exports/share"
# Ensure the start-desktop.sh script is executable
chmod +x /usr/bin/start-desktop.sh
# Set the default background for gnome based desktop
# Set the default background
mkdir -p /etc/alternatives
ln -sf /usr/share/backgrounds/steam.jpg /etc/alternatives/desktop-background
chmod a+r /etc/alternatives/desktop-background

View File

@@ -13,9 +13,9 @@ else
# Ensure pulseaudio directories have the correct permissions
mkdir -p \
${PULSE_SOCKET_DIR} \
/home/${USER}/.config/pulse
${USER_HOME:?}/.config/pulse
chmod -R a+rw ${PULSE_SOCKET_DIR}
chown -R ${PUID}:${PGID} /home/${USER}/.config/pulse
chown -R ${PUID}:${PGID} ${USER_HOME:?}/.config/pulse
# Configure the palse audio socket
sed -i "s|^; default-server.*$|default-server = ${PULSE_SERVER}|" /etc/pulse/client.conf
@@ -30,9 +30,6 @@ else
if [ "X${DEBUGGING:-}" == "X" ]; then
sed -i 's|^; log-level.*$|log-level = debug|' /etc/pulse/daemon.conf
fi
# Make startup script executable
chmod +x /usr/bin/start-pulseaudio.sh
fi
chown -R ${USER} /etc/pulse

View File

@@ -46,7 +46,7 @@ function configure_nvidia_x_server {
sed -i '/Driver\s\+"nvidia"/a\ Option "ModeValidation" "NoMaxPClkCheck, NoEdidMaxPClkCheck, NoMaxSizeCheck, NoHorizSyncCheck, NoVertRefreshCheck, NoVirtualSizeCheck, NoTotalSizeCheck, NoDualLinkDVICheck, NoDisplayPortBandwidthCheck, AllowNon3DVisionModes, AllowNonHDMI3DModes, AllowNonEdidModes, NoEdidHDMI2Check, AllowDpInterlaced"\n Option "HardDPMS" "False"' /etc/X11/xorg.conf
sed -i '/Section\s\+"Monitor"/a\ '"${MODELINE}" /etc/X11/xorg.conf
# Prevent interference between GPUs
echo -e "Section \"ServerFlags\"\n Option \"AutoAddGPU\" \"false\"\nEndSection" | sudo tee -a /etc/X11/xorg.conf > /dev/null
echo -e "Section \"ServerFlags\"\n Option \"AutoAddGPU\" \"false\"\nEndSection" | tee -a /etc/X11/xorg.conf > /dev/null
# Configure primary GPU
sed -i '/Driver\s\+"nvidia"/a\ Option "AllowEmptyInitialConfiguration"\n Option "PrimaryGPU" "yes"' /usr/share/X11/xorg.conf.d/nvidia-drm-outputclass.conf
}

View File

@@ -5,7 +5,6 @@ if ([ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then
if [ ! -S /var/run/docker.sock ]; then
echo "Enable Dockerd daemon"
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/dind.ini
chmod +x /usr/bin/start-dind.sh
else
echo "Docker socket has been passed in from host. Using that instead"
fi
@@ -14,9 +13,9 @@ if ([ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then
echo "Add user '${USER}' to docker group for sudoless execution"
groupadd docker
usermod -aG docker ${USER}
mkdir -p /home/${USER}/.docker
chown -R ${PUID}:${PGID} /home/${USER}/.docker
chmod -R g+rwx /home/${USER}/.docker
mkdir -p ${USER_HOME:?}/.docker
chown -R ${PUID}:${PGID} ${USER_HOME:?}/.docker
chmod -R g+rwx ${USER_HOME:?}/.docker
fi
else
echo "Dockerd daemon not available when container is run in 'secondary' mode"

View File

@@ -5,7 +5,6 @@ if ([ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then
if [ "${ENABLE_SUNSHINE:-}" = "true" ]; then
echo "Enable Sunshine server"
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/sunshine.ini
chmod +x /usr/bin/start-sunshine.sh
else
echo "Disable Sunshine server"
fi

View File

@@ -12,5 +12,3 @@ PS1='[\u@\h \W]\$ '
PATH=$PATH:$HOME/.local/bin:$HOME/bin
# Export /usr/games
PATH=$PATH:/usr/games
# Export flatpak data directories
XDG_DATA_DIRS="${XDG_DATA_DIRS}:/var/lib/flatpak/exports/share:/home/${USER}/.local/share/flatpak/exports/share"

View File

@@ -4,11 +4,10 @@ Version=0.9.4
Type=Application
Name=Steam
Comment=launch steam on login
Exec=/usr/games/steam %U -silent
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=/app/bin/steam-wrapper --file-forwarding com.valvesoftware.Steam @@u %U @@ -silent
Icon=steam
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
echo "**** Installing/upgrading Firefox via flatpak ****"
# Install Firefox
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install --assumeyes --noninteractive --or-update flathub org.mozilla.firefox
# Configure Firefox as the default browser
echo "Configure Firefox..."
custom_webbrowser="$(cat <<EOF
"libraryfolders"
[Desktop Entry]
NoDisplay=true
Version=1.0
Encoding=UTF-8
Type=X-XFCE-Helper
X-XFCE-Category=WebBrowser
X-XFCE-CommandsWithParameter=${USER_HOME:?}/.local/share/flatpak/exports/bin/org.mozilla.firefox "%s"
Icon=org.mozilla.firefox
Name=org.mozilla.firefox
X-XFCE-Commands=${USER_HOME:?}/.local/share/flatpak/exports/bin/org.mozilla.firefox
EOF
)"
if [[ ! -f ${USER_HOME:?}/.local/share/xfce4/helpers/custom-WebBrowser.desktop ]]; then
mkdir -p ${USER_HOME:?}/.local/share/xfce4/helpers
echo "${custom_webbrowser}" > ${USER_HOME:?}/.local/share/xfce4/helpers/custom-WebBrowser.desktop
gio mime x-scheme-handler/http org.mozilla.firefox.desktop
fi
echo "DONE"

View File

@@ -1,89 +0,0 @@
#!/usr/bin/env bash
###
# File: install_heroic.sh
# Project: scripts
# File Created: Thursday, 1st January 1970 12:00:00 pm
# Author: Console and webGui login account (jsunnex@gmail.com)
# -----
# Last Modified: Wednesday, 31st August 2022 10:01:31 pm
# Modified By: Josh.5 (jsunnex@gmail.com)
###
pkg=heroic
script_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
script_name=$( basename "${BASH_SOURCE[0]}" )
github_get_all_release() {
REPO="${1}";
curl --silent "https://api.github.com/repos/${REPO}/releases" \
| grep '"tag_name":' \
| sed -E 's/.*"([^"]+)".*/\1/';
}
github_get_release_download_url() {
REPO="${1}";
TAG="${2}";
TYPE="${3}";
IGNORE="${4}";
curl --silent "https://api.github.com/repos/${REPO}/releases/tags/${TAG}" \
| grep '"browser_download_url":' \
| sed -E 's/.*"([^"]+)".*/\1/' \
| grep -P "${TYPE}" \
| grep -P "${TYPE}" \
| head -n1;
}
install() {
# Download Heroic deb package if it does not yet exist
__latest_heroic_release=$(github_get_all_release "Heroic-Games-Launcher/HeroicGamesLauncher" | head -n1)
if [[ ! -f "/home/${USER}/Downloads/heroic-${__latest_heroic_release}.deb" ]]; then
__heroic_download_link=$(github_get_release_download_url "Heroic-Games-Launcher/HeroicGamesLauncher" "${__latest_heroic_release}" ".deb")
wget -O /tmp/heroic.deb "${__heroic_download_link}"
[[ $? -gt 0 ]] && echo "Error downloading pacakge. Exit!" && return 1
mv /tmp/heroic.deb "/home/${USER}/Downloads/heroic-${__latest_heroic_release}.deb"
fi
# Install/Update the latest version of Heroic
[[ "${APT_UPDATED:-false}" == 'false' ]] && apt-get update && APT_UPDATED=true
apt-get install -y "/home/${USER}/Downloads/heroic-${__latest_heroic_release}.deb"
# Install/Update deps for HeroicBashLauncher
[[ "${APT_UPDATED:-false}" == 'false' ]] && apt-get update && APT_UPDATED=true
apt-get install -y zenity
# Install/Update the latest version HeroicBashLauncher
__latest_hbl_release=$(github_get_all_release "redromnon/HeroicBashLauncher" | head -n1)
if [[ ! -e "/home/${USER}/HeroicBashLauncher/.${__latest_hbl_release}" ]]; then
# Download HeroicBashLauncher
if [[ ! -f "/home/${USER}/Downloads/HeroicBashLauncher-${__latest_hbl_release}.zip" ]]; then
__hbl_download_link=$(github_get_release_download_url "redromnon/HeroicBashLauncher" "${__latest_hbl_release}" "\d\.zip")
wget -O /tmp/hbl.zip "${__hbl_download_link}"
[[ $? -gt 0 ]] && echo "Error downloading pacakge. Exit!" && return 1
mv /tmp/hbl.zip "/home/${USER}/Downloads/HeroicBashLauncher-${__latest_hbl_release}.zip"
fi
# Extract HeroicBashLauncher
mkdir -p "/home/${USER}/HeroicBashLauncher"
rm -rf "/tmp/hbl"
su ${USER} -c "mkdir -p /tmp/hbl && cd /tmp/hbl && unzip -o /home/${USER}/Downloads/HeroicBashLauncher-${__latest_hbl_release}.zip"
su ${USER} -c "cp -rfv /tmp/hbl/HeroicBashLauncher*/HeroicBashLauncher/* /home/${USER}/HeroicBashLauncher/"
chmod +x "/home/${USER}/HeroicBashLauncher/HeroicBashLauncher"
# Setup script in user PATH
su ${USER} -c "mkdir -p /home/default/.local/bin"
su ${USER} -c "ln -sf /home/${USER}/HeroicBashLauncher/HeroicBashLauncher /home/${USER}/.local/bin/HeroicBashLauncher"
fi
# Remove installer shortcut
rm -f /usr/share/applications/install.heroic.desktop
}
#INSTALLER:
source "${script_path}/installer.sh"

View File

@@ -1,70 +0,0 @@
#!/usr/bin/env bash
###
# File: install_legendary.sh
# Project: scripts
# File Created: Thursday, 1st January 1970 12:00:00 pm
# Author: Console and webGui login account (jsunnex@gmail.com)
# -----
# Last Modified: Sunday, 16th January 2022 5:44:25 am
# Modified By: Console and webGui login account (jsunnex@gmail.com)
###
pkg=legendary
script_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
script_name=$( basename "${BASH_SOURCE[0]}" )
github_get_all_release() {
REPO="${1}";
curl --silent "https://api.github.com/repos/${REPO}/releases" \
| grep '"tag_name":' \
| sed -E 's/.*"([^"]+)".*/\1/';
}
install() {
if ! command -v ${pkg} >/dev/null; then
# Download/install the latest legendary binary
latest_release=$(github_get_all_release derrod/legendary | head -n1)
download_url="https://github.com/derrod/legendary/releases/download/${latest_release}/legendary"
wget -O "/tmp/legendary-${latest_release}" "${download_url}"
chmod +x /tmp/legendary-${latest_release}
cp -f /tmp/legendary-${latest_release} /usr/bin/legendary-${latest_release}
rm -f /usr/bin/legendary
ln -s /usr/bin/legendary-${latest_release} /usr/bin/legendary
fi
if ! command -v rare >/dev/null; then
# Install rare for a gui
python3 -m pip install Rare
fi
if ! command -v steam-legendary-wrapper >/dev/null; then
# Download/install the steam-legendary-wrapper script
wget -O "/tmp/steam-legendary-wrapper.sh" \
"https://raw.githubusercontent.com/toalex77/steam-legendary-wrapper/main/steam-legendary-wrapper.sh"
chmod +x /tmp/steam-legendary-wrapper.sh
rm -f /usr/bin/steam-legendary-wrapper
cp -f /tmp/steam-legendary-wrapper.sh /usr/bin/steam-legendary-wrapper
fi
# Remove installer shortcut
rm -f /usr/share/applications/install.legendary.desktop
# Add launcher shortcut
cat << EOF > /usr/share/applications/rare.desktop
[Desktop Entry]
Name=Rare - (Epic Games Store)
Comment=A frontend for legendary, the open source Epic Games Store alternative
GenericName=Rare - (Epic Games Store)
X-GNOME-FullName=Rare - (Epic Games Store)
Exec=/usr/local/bin/rare %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=rare
Categories=Game;
EOF
}
#INSTALLER:
source "${script_path}/installer.sh"

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env bash
###
# File: install_lutris.sh
# Project: scripts
# File Created: Thursday, 1st January 1970 12:45:00 pm
# Author: Console and webGui login account (jsunnex@gmail.com)
# -----
# Last Modified: Sunday, 16th January 2022 4:54:11 am
# Modified By: Console and webGui login account (jsunnex@gmail.com)
###
pkg=lutris
script_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
script_name=$( basename "${BASH_SOURCE[0]}" )
install() {
if ! dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
echo "deb http://download.opensuse.org/repositories/home:/strycore/Debian_10/ ./" | tee /etc/apt/sources.list.d/lutris.list
wget -q https://download.opensuse.org/repositories/home:/strycore/Debian_10/Release.key -O- | apt-key add -
apt-get update
apt-get -y install \
lutris \
python3-dbus
sed -i '/Exec=lutris %U/c\Exec=/usr/games/lutris %U' /usr/share/applications/net.lutris.Lutris.desktop
fi
# Remove installer shortcut
rm -f /usr/share/applications/install.lutris.desktop
}
#INSTALLER:
source "${script_path}/installer.sh"

38
overlay/opt/scripts/install_protonup.sh Normal file → Executable file
View File

@@ -1,34 +1,14 @@
#!/usr/bin/env bash
###
# File: install_protonup.sh
# Project: scripts
# File Created: Thursday, 1st January 1970 12:45:00 pm
# Author: Console and webGui login account (jsunnex@gmail.com)
# -----
# Last Modified: Sunday, 16th January 2022 4:55:12 am
# Modified By: Console and webGui login account (jsunnex@gmail.com)
###
pkg=protonup-ng
script_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
script_name=$( basename "${BASH_SOURCE[0]}" )
echo "**** Installing/upgrading ProtonUp-Qt via flatpak ****"
# Install ProtonUp-Qt
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install --assumeyes --noninteractive --or-update net.davidotek.pupgui2
install() {
if ! command -v ${pkg} >/dev/null; then
# Install application
python3 -m pip install ${pkg}
# Set installation path as user
# Note: Run command with su because init processes are run as root but this is a user thing...
su ${USER} -c "${pkg} -d '/home/${USER}/.steam/root/compatibilitytools.d/'"
# Update to the latest version on startup using the users Downloads directory
su ${USER} -c "${pkg} -y -o '/home/${USER}/Downloads/'" &
fi
# Configure Firefox as the default browser
echo "Configure ProtonUp-Qt..."
sed -i 's/^Categories=.*$/Categories=Utility;/' \
${USER_HOME}/.local/share/flatpak/exports/share/applications/net.davidotek.pupgui2.desktop
# Remove installer shortcut
rm -f /usr/share/applications/install.protonup.desktop
}
#INSTALLER:
source "${script_path}/installer.sh"
echo "DONE"

View File

@@ -0,0 +1,54 @@
#!/usr/bin/env bash
echo "**** Installing/upgrading Steam via flatpak ****"
# Install Steam client
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install --assumeyes --noninteractive --or-update flathub com.valvesoftware.Steam
# Configure any required overrides
flatpak --user override --filesystem=/mnt/games com.valvesoftware.Steam
# TODO: Check if we should add /dev/dri here??
# Configure default steam library paths
echo "Configure Steam default libraries..."
mkdir -p /mnt/games/GameLibrary/SteamLibrary
libraryfolders="$(cat <<EOF
"libraryfolders"
{
"0"
{
"path" "${USER_HOME:?}/.var/app/com.valvesoftware.Steam/.local/share/Steam"
"label" ""
"contentid" "5619710282499379610"
"totalsize" "0"
"update_clean_bytes_tally" "0"
"time_last_update_corruption" "0"
"apps"
{
}
}
"1"
{
"path" "/mnt/games/GameLibrary/SteamLibrary"
"label" "Mounted Games"
"contentid" "4437054932394438372"
"totalsize" "0"
"update_clean_bytes_tally" "0"
"time_last_update_corruption" "0"
"apps"
{
}
}
}
EOF
)"
if [[ ! -f ${USER_HOME:?}/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/libraryfolders.vdf ]]; then
mkdir -p ${USER_HOME:?}/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps
echo "${libraryfolders}" > ${USER_HOME:?}/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/libraryfolders.vdf
fi
if [[ ! -f ${USER_HOME:?}/.var/app/com.valvesoftware.Steam/.local/share/Steam/config/libraryfolders.vdf ]]; then
mkdir -p ${USER_HOME:?}/.var/app/com.valvesoftware.Steam/.local/share/Steam/config
echo "${libraryfolders}" > ${USER_HOME:?}/.var/app/com.valvesoftware.Steam/.local/share/Steam/config/libraryfolders.vdf
fi
echo "DONE"

View File

@@ -1,28 +0,0 @@
if [[ "${script_path}" == *"opt/script"* ]]; then
while true; do
echo
read -p "Would you like to configure this container to install ${pkg^} on startup? (Y/N) " ans
case $ans in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
# Install this script to the home directory init.d
dest_file="/home/${USER}/init.d/${script_name}"
cp -f "${script_path}/${script_name}" "${dest_file}"
# Remove anything under '#INSTALLER:'
sed -i '/^#INSTALLER.*$/Q' "${dest_file}"
# Append 'install' command
echo 'install' >> "${dest_file}"
echo
echo
echo "Installed init script '${dest_file}'"
echo "This script will install ${pkg^} when you next restart the container."
echo
read -s -p "Press enter to continue"
echo
fi

View File

@@ -5,7 +5,7 @@
# File Created: Thursday, 1st January 1970 12:00:00 pm
# Author: Console and webGui login account (jsunnex@gmail.com)
# -----
# Last Modified: Wednesday, 26th January 2022 5:38:23 pm
# Last Modified: Saturday, 8th July 2023 2:34:11 am
# Modified By: Console and webGui login account (jsunnex@gmail.com)
###
set -e
@@ -19,27 +19,23 @@ trap _term SIGTERM SIGINT
# CONFIGURE:
XDG_DATA_DIRS="${XDG_DATA_DIRS}:/var/lib/flatpak/exports/share:/home/${USER}/.local/share/flatpak/exports/share"
export $(dbus-launch)
# EXECUTE PROCESS:
# Install/Upgrade user apps
if [[ ! -f /tmp/.desktop-apps-updated.lock ]]; then
source /opt/scripts/install_steam.sh
source /opt/scripts/install_firefox.sh
source /opt/scripts/install_protonup.sh
touch /tmp/.desktop-apps-updated.lock
fi
# Wait for the X server to start
wait_for_x
# Run the desktop environment in order of priority
if [[ -e /usr/bin/cinnamon-session ]]; then
/usr/bin/cinnamon-session --display=${DISPLAY} &
desktop_pid=$!
elif [[ -e /usr/bin/mate-session ]]; then
/usr/bin/mate-session &
desktop_pid=$!
elif [[ -e /usr/bin/startplasma-x11 ]]; then
/usr/bin/startplasma-x11 &
desktop_pid=$!
elif [[ -e /usr/bin/startxfce4 ]]; then
/usr/bin/startxfce4 &
desktop_pid=$!
fi
# Run the desktop environment
echo "**** Starting Xfce4 ****"
/usr/bin/startxfce4 &
desktop_pid=$!
# WAIT FOR CHILD PROCESS:

View File

@@ -1,7 +0,0 @@
[Desktop Entry]
Name=Installer - Heroic (Epic Games Launcher)
Categories=Game;
Exec=/opt/scripts/install_heroic.sh %U
Icon=installsoftware
Terminal=true
Type=Application

View File

@@ -1,7 +0,0 @@
[Desktop Entry]
Name=Installer - Rare/Legendary (Epic Games Commandline Launcher)
Categories=Game;
Exec=/opt/scripts/install_legendary.sh %U
Icon=installsoftware
Terminal=true
Type=Application

View File

@@ -1,7 +0,0 @@
[Desktop Entry]
Name=Installer - Lutris
Categories=Game;
Exec=/opt/scripts/install_lutris.sh %U
Icon=installsoftware
Terminal=true
Type=Application

View File

@@ -1,7 +0,0 @@
[Desktop Entry]
Name=Installer - Protonup
Categories=Game;
Exec=/opt/scripts/install_protonup.sh %U
Icon=installsoftware
Terminal=true
Type=Application