1

Rework setup script

This commit is contained in:
Jessie Hildebrandt 2024-04-13 21:26:42 -04:00
parent baaa92440a
commit b7afd9dfca

View File

@ -2,7 +2,7 @@
################################################################################
#
# opensuse-personalizer.sh
# opensuse-setup.sh
# Interactive post-install setup script for OpenSUSE installations
#
################################################################################
@ -34,7 +34,7 @@ PATTERNS=(
# To remove
RM=(
yast2-* nautilus-share MozillaFirefox-branding-openSUSE
yast2-* nautilus-share nautilus-sendto MozillaFirefox-branding-openSUSE
)
# To remove (and prevent reinstallation of)
@ -51,7 +51,7 @@ IN=(
papirus-icon-theme fira-code-fonts gdouros-symbola-fonts google-noto-sans-cjk-fonts google-noto-coloremoji-fonts noto-fonts fetchmsttfonts
# (Shell utilities)
fish fzf ispell zenity fortune toilet cowsay wmctrl libnotify-tools ripgrep
fish fzf ispell zenity fortune toilet cowsay wmctrl libnotify-tools ripgrep jq
# (Programs)
emacs inkscape gimp shotcut audacity geary nextcloud-desktop steam blender
@ -60,7 +60,7 @@ IN=(
MozillaFirefox-branding-upstream MozillaFirefox
# (GNOME utilities)
gnome-session-wayland gnome-characters gnome-disk-utility gnome-font-viewer gnome-dictionary gnome-logs gnome-screenshot gnome-weather loupe dconf-editor baobab totem menulibre Fragments
loupe dconf-editor baobab totem menulibre Fragments rsvg-thumbnailer gnome-session-wayland gnome-characters gnome-disk-utility gnome-font-viewer gnome-dictionary gnome-logs gnome-screenshot gnome-weather
# (Dependencies)
webp-pixbuf-loader
@ -105,12 +105,7 @@ PACKMAN_REPO_URL="https://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Tumbl
FLATHUB_REMOTE_URL="https://flathub.org/repo/flathub.flatpakrepo"
PERSONALIZER_REPO_URL="https://gitlab.com/jessieh/opensuse-personalizer.git"
########################################
# Directories and files
PERSONALIZER_REPO_DIR=/tmp/opensuse-personalizer
REPOS_API_URL="https://git.tty.dog/api/v1/repos/search"
################################################################################
#
@ -122,7 +117,7 @@ PERSONALIZER_REPO_DIR=/tmp/opensuse-personalizer
# Pre-setup
# Ensure we're not running as root
if [ "${EUID}" == 0 ]; then
if [[ "${EUID}" == 0 ]]; then
echo "DO NOT RUN THIS SCRIPT AS ROOT!"
echo "Please run this script as a regular user."
exit 1
@ -148,7 +143,6 @@ function string_eq ()
function prompt_chassis_type ()
{
entry=$(dialog --title "Chassis Type" --stdout --no-cancel --erase-on-exit \
--radiolist "Confirm the chassis type for this system:" 0 0 0 \
"Desktop" "Stationary form factor" $(string_eq "${system_chassis}" "desktop") \
@ -460,6 +454,7 @@ function add_custom_gnome_keybinding ()
# Add custom shortcuts
add_custom_gnome_keybinding "Launch Terminal" "gnome-terminal" "<Super>Return"
add_custom_gnome_keybinding "Launch System Monitor" "gnome-system-monitor" "<Shift><Control>Escape"
add_custom_gnome_keybinding "Toggle Night Light" "gnome-toggle-night-light" "<Alt><Super>n"
# (OPTIONAL) Add custom shortcuts
@ -490,6 +485,7 @@ gsettings set org.gnome.desktop.interface font-name "Cantarell 10"
gsettings set org.gnome.desktop.interface document-font-name "Cantarell 10"
gsettings set org.gnome.desktop.interface monospace-font-name "Fira Code 10"
gsettings set org.gnome.desktop.wm.preferences auto-raise true
gsettings set org.gnome.desktop.wm.preferences action-middle-click-titlebar "minimize"
gsettings set org.gnome.desktop.notifications show-in-lock-screen false
@ -553,6 +549,54 @@ done
#
################################################################################
########################################
# Projects folder setup
echo "Setting up Projects folder..."
# Ensure ${HOME}/Projects exists and set it as the working directory
PROJECTS_DIR=${HOME}/Projects
if [ ! -d ${PROJECTS_DIR} ]; then
mkdir ${PROJECTS_DIR}
gio set ${PROJECTS_DIR} metadata::custom-icon-name folder-code
fi
# Perform a blobless clone of all public repos at git.tty.dog
API_URL="https://git.tty.dog/api/v1/repos/search"
for CLONE_URL in $(curl -s "${API_URL}?uid=1" | jq -r ".data.[].clone_url"); do
git clone --no-checkout --filter=blob:none "${CLONE_URL}" ${PROJECTS_DIR}
done
########################################
# Dotfiles
echo "Setting up dotfiles..."
# Download dotfiles
DOTFILES_SOURCE_DIR=${PROJECTS_DIR}/dot-files
git -C ${DOTFILES_SOURCE_DIR} checkout
# Link application entries
mkdir -p ${HOME}/.local/share/applications
ln -s ${DOTFILES_SOURCE_DIR}/applications/* ${HOME}/.local/share/applications
# Link scripts
mkdir -p ${HOME}/.local/bin
ln -s ${DOTFILES_SOURCE_DIR}/bin/* ${HOME}/.local/bin
# Copy configuration files
mkdir -p ${HOME}/.config
cp -r ${DOTFILES_SOURCE_DIR}/config/* ${HOME}/.config/
# (OPTIONAL) Remove unneeded files, depending on features selected
if [[ "${detected_features[@]}" != *'Touchpad'* ]]; then
rm ${HOME}/.local/bin/gnome-toggle-touchpad-lock
fi
if [[ "${detected_features[@]}" != *'Windows'* ]]; then
rm ${HOME}/.local/share/applications/windows.desktop
rm ${HOME}/.local/bin/reboot-windows
fi
########################################
# Emacs
@ -561,10 +605,18 @@ echo "Setting up Emacs..."
# Remove any vendor-provided Emacs configuration files
rm ${HOME}/.emacs ${HOME}/.emacs.d/init.el
# Download Emacs configuration
# Download and link Emacs configuration
EMACS_CONFIG_DIR=${HOME}/.config/emacs
EMACS_SOURCE_DIR=${PROJECTS_DIR}/dot-emacs
mkdir -p ${EMACS_CONFIG_DIR}
wget https://jessieh.net/emacs -O ${EMACS_CONFIG_DIR}/init.el
git -C ${EMACS_SOURCE_DIR} checkout
ln -s ${EMACS_SOURCE_DIR}/init.el ${EMACS_CONFIG_DIR}/init.el
# Download and link Tempel templates for Emacs...
TEMPEL_CONFIG_DIR=${HOME}/.config/emacs/templates
TEMPEL_SOURCE_DIR=${PROJECTS_DIR}/tempel-templates
git -C ${TEMPEL_SOURCE_DIR} checkout
ln -s ${TEMPEL_SOURCE_DIR} ${TEMPEL_CONFIG_DIR}
# Enable and start Emacs daemon
systemctl --user enable emacs.service
@ -575,45 +627,16 @@ systemctl --user start emacs.service
echo "Setting up Fish..."
# Download Fish configuration
# Download and link Fish configuration
FISH_CONFIG_DIR=${HOME}/.config/fish
FISH_SOURCE_DIR=${PROJECTS_DIR}/dot-fish
mkdir -p ${FISH_CONFIG_DIR}
wget https://jessieh.net/fish -O ${FISH_CONFIG_DIR}/config.fish
git -C ${FISH_SOURCE_DIR} checkout
ln -s ${FISH_SOURCE_DIR}/config.fish ${FISH_CONFIG_DIR}/config.fish
# Set Fish as default shell
sudo chsh ${USER} -s $(which fish)
########################################
# Utility scripts
echo "Installing scripts..."
# Clone personalizer repo containing scripts, desktop entries, etc. to temporary folder
git clone "${PERSONALIZER_REPO_URL}" "${PERSONALIZER_REPO_DIR}"
if [[ "${detected_features[@]}" != *'Touchpad'* ]]; then
rm ${PERSONALIZER_REPO_DIR}/scripts/gnome-toggle-touchpad-lock
fi
if [[ "${detected_features[@]}" != *'Windows'* ]]; then
rm ${PERSONALIZER_REPO_DIR}/scripts/reboot-windows
fi
chmod +x ${PERSONALIZER_REPO_DIR}/scripts/*
sudo cp ${PERSONALIZER_REPO_DIR}/scripts/* /usr/bin
########################################
# Desktop entries
echo "Installing desktop entries..."
if [[ "${detected_features[@]}" != *'Windows'* ]]; then
rm ${PERSONALIZER_REPO_DIR}/desktop_entries/windows.desktop
fi
mkdir -p ${HOME}/.local/share/applications/
cp ${PERSONALIZER_REPO_DIR}/desktop-entries/* ${HOME}/.local/share/applications/
################################################################################
#
# Post-setup suggestions