fix(user-setup): Improve language-sensible templates setup (#1180)

* fix(user-setup): Use correct templates directory depending of language

Use 'xdg-user-dirs' to obtain a localized path to templates directory (with '$HOME/Templates' as fallback.
Should fix any related issues with Gnome nautilus not detecting templates using other language that english.

* fix(bazzite-user-setup): Add checks before creating templates symlinks

Check if the template files exists in `/etc` before creating the symlinks, otherwise do not create them.

Using only '[[ ! -f file ]]' always returns true in the case of a broken symlink, as per quote of `man test`:

> Except  for  -h  and  -L,  all FILE-related tests dereference symbolic links.

In consequence, it checks the symlink file is pointing to, not tne existence of the symlink itself, thus ends up attempting to overwrite the later.

* chore: Increase setup script version

---------

Co-authored-by: Kyle Gospodnetich <me@kylegospodneti.ch>
This commit is contained in:
Zeglius 2024-05-27 06:55:16 +02:00 committed by GitHub
parent c7df02acd8
commit 8c97326322
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,7 +17,7 @@ BAZZITE_CONFIG_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/bazzite"
mkdir -p "$BAZZITE_CONFIG_DIR"
# SCRIPT VERSION
USER_SETUP_VER=33
USER_SETUP_VER=34
USER_SETUP_VER_FILE="$BAZZITE_CONFIG_DIR/version"
USER_SETUP_FEDORA_VER_FILE="$BAZZITE_CONFIG_DIR/fedora_version"
USER_SETUP_IMAGE_VER_FILE=$BAZZITE_CONFIG_DIR/image_name""
@ -117,12 +117,18 @@ else
fi
echo 'Setting up templates'
mkdir -p "$HOME/Templates"
if [[ ! -f "$HOME/Templates/vkBasalt.conf" ]]; then
ln -s "/etc/vkBasalt.conf" "$HOME/Templates/vkBasalt.conf"
TEMPLATES_DIR=$(/usr/bin/xdg-user-dir TEMPLATES || true)
if [[ -z "$TEMPLATES_DIR" || "$TEMPLATES_DIR" == "$HOME" ]]; then
# xdg-user-dir might return only $HOME, in that case, use fallback $HOME/Templates.
echo "Using fallback '$HOME/Templates'"
TEMPLATES_DIR="$HOME/Templates"
fi
if [[ ! -f "$HOME/Templates/dxvk.conf" ]]; then
ln -s "/etc/dxvk-example.conf" "$HOME/Templates/dxvk.conf"
mkdir -p "$TEMPLATES_DIR"
if [[ ! -f "$TEMPLATES_DIR/vkBasalt.conf" && -f "/etc/vkBasalt.conf" ]]; then
ln -s "/etc/vkBasalt.conf" "$TEMPLATES_DIR/vkBasalt.conf"
fi
if [[ ! -f "$TEMPLATES_DIR/dxvk.conf" && -f "/etc/dxvk-example.conf" ]]; then
ln -s "/etc/dxvk-example.conf" "$TEMPLATES_DIR/dxvk.conf"
fi
echo 'Tweaking GNOME indexer'