From 3b1aea51593a5fbc01ce0ab54eeed5a30a02bb98 Mon Sep 17 00:00:00 2001 From: Jessie Hildebrandt Date: Fri, 2 Jun 2023 11:46:34 -0400 Subject: [PATCH] Modify personalizer for use from barebones system --- opensuse-personalizer.sh | 139 ++++++++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 54 deletions(-) diff --git a/opensuse-personalizer.sh b/opensuse-personalizer.sh index 35f8580..d3c7059 100755 --- a/opensuse-personalizer.sh +++ b/opensuse-personalizer.sh @@ -13,6 +13,19 @@ # ################################################################################ +######################################## +# OpenSUSE patterns + +PATTERNS=( + # (Base system) + patterns-base-apparmor + patterns-base-base + patterns-base-enhanced_base + + # (Desktop environment) + patterns-gnome-gnome_basic +) + ######################################## # Zypper packages @@ -29,13 +42,13 @@ AL=( # To install IN=( # (Necessary packages) - wget nano git-core flatpak opi + git-core flatpak opi # (Theming) papirus-icon-theme fira-code-fonts gdouros-symbola-fonts # (Shell utilities) - fish fzf fortune toilet cowsay wmctrl libnotify-tools + fish fzf nano zenity fortune toilet cowsay wmctrl libnotify-tools # (Programs) emacs inkscape gimp shotcut audacity geary nextcloud-desktop steam blender @@ -67,10 +80,16 @@ GNOME_EXTENSIONS=( ) ######################################## -# Directories +# URLs -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -TMP_WORKDIR="/tmp/opensuse-setup-script-workdir/" +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 ################################################################################ # @@ -88,9 +107,9 @@ if [ "${EUID}" == 0 ]; then exit 1 fi -# Ensure zenity is installed -echo "Ensuring zenity is installed..." -sudo zypper --non-interactive in zenity +# Ensure "dialog" is installed +echo "Installing dialog utility..." +sudo zypper --non-interactive in dialog ######################################## # Prompt for system chassis @@ -99,19 +118,19 @@ system_chassis=$(hostnamectl chassis) function string_eq () { - [[ "${1}" == "${2}" ]] && echo TRUE || echo FALSE + [[ "${1}" == "${2}" ]] && echo ON || echo OFF } function prompt_chassis_type () { - entry=$(zenity --title="Chassis Type" --list --radiolist --width=200 --height=400 \ - --text="Confirm the chassis type for this system:\n" \ - --column="Selected" --column="Chassis Type" \ - $(string_eq "${system_chassis}" "desktop") "Desktop" \ - $(string_eq "${system_chassis}" "laptop") "Laptop" \ - $(string_eq "${system_chassis}" "tablet") "Tablet" \ - $(string_eq "${system_chassis}" "convertible") "Convertible") + + 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") \ + "Laptop" "Clamshell form factor" $(string_eq "${system_chassis}" "laptop") \ + "Tablet" "Touchscreen form factor" $(string_eq "${system_chassis}" "tablet") \ + "Convertible" "Hybrid form factor" $(string_eq "${system_chassis}" "convertible")) # Ensure entry is lowercase entry=${entry,,} @@ -120,7 +139,7 @@ function prompt_chassis_type () case "${entry}" in "desktop"|"laptop"|"convertible"|"tablet") if - zenity --question --title="Chassis Type" --text="Use ${entry} as chassis type?" --default-cancel --no-wrap + dialog --title "Chassis Type" --defaultno --yesno "Use ${entry} as chassis type?" 0 0 then system_chassis="${entry}" return 0 @@ -129,7 +148,7 @@ function prompt_chassis_type () fi ;; *) - zenity --warning --title="Chassis Type" --text="Please choose a chassis type for this system." --no-wrap + dialog --title "Chassis Type" --msgbox "Please choose a chassis type for this system." 0 0 return 1 ;; esac @@ -151,7 +170,9 @@ system_name=$(hostnamectl hostname) function prompt_system_name () { - entry=$(zenity --entry --title="System Name" --text="All lowercase letters, no spaces or symbols:" --entry-text="${system_name}") + entry=$(dialog --title "System Name" --stdout --no-cancel --erase-on-exit \ + --inputbox "All lowercase letters, no spaces or symbols:" 0 0 \ + "${system_name}") # Filter all non-letter characters out of the user's entry entry=${entry//[^[:alpha:]]/} @@ -161,12 +182,12 @@ function prompt_system_name () case "${entry}" in "") - zenity --warning --title="System Name" --text="Please enter a name for this system." --no-wrap + dialog --title "Chassis Type" --msgbox "Please enter a name for this system." 0 0 return 1 ;; *) if - zenity --question --title="System Name" --text="Use ${entry} as system name?" --default-cancel --no-wrap + dialog --title "Chassis Type" --defaultno --yesno "Use ${entry} as system name?" 0 0 then system_name="${entry}" return 0 @@ -195,20 +216,21 @@ optional_additions="" function prompt_optional_additions () { - ENTRY=$(zenity --title="Optional Additions" --list --checklist --width=600 --height=440 \ - --text="Select any additional configuration changes that you would like applied to the system:\n" \ - --column="Apply" --column="Title" --column="Description" \ - FALSE "Xournal++" "Install Xournal++ for taking handwritten notes" \ - FALSE "EasyEffects" "Install EasyEffects for applying effects (e.g. equalizers) to system audio devices" \ - FALSE "Media Control Key Shortcuts" "Set up media control keyboard shortcuts (for keyboards without dedicated media control keys)" \ - FALSE "Touchpad Lock Toggle Shortcut" "Set up a touchpad lock toggle keyboard shortcut (for systems with touchpads)" \ - FALSE "Power Button Screen Lock Override" "Override the power button's default behavior with a screen lock shortcut (for tablets or convertibles)" \ - FALSE '"Reboot to Windows" Launcher' "Install a desktop entry that reboots the system to Microsoft Windows (for systems that multi-boot with Windows)") + + ENTRY=$(dialog --title "Optional Additions" --stdout --no-cancel --single-quoted --output-separator '|' \ + --checklist "Select any additional configuration changes that you would like applied to the system:" 0 0 0 \ + "Xournal++" "Install Xournal++ for taking handwritten notes" OFF \ + "EasyEffects" "Install EasyEffects for applying effects (e.g. equalizers) to system audio devices" OFF \ + "Media Control Key Shortcuts" "Set up media control keyboard shortcuts (for keyboards without dedicated media control keys)" OFF \ + "Touchpad Lock Toggle Shortcut" "Set up a touchpad lock toggle keyboard shortcut (for systems with touchpads)" OFF \ + "Power Button Screen Lock Override" "Override the power button's default behavior with a screen lock shortcut (for tablets or convertibles)" OFF \ + '"Reboot to Windows" Launcher' "Install a desktop entry that reboots the system to Microsoft Windows (for systems that multi-boot with Windows)" OFF ) + case "${ENTRY}" in "") if - zenity --question --title="Optional Additions" --text="Apply only baseline system configuration?" --default-cancel --no-wrap + dialog --keep-window --erase-on-exit --title "Chassis Type" --defaultno --yesno "Apply only baseline system configuration?" 0 0 then return 0 else @@ -217,8 +239,8 @@ function prompt_optional_additions () ;; *) if - ADDITIONS_LIST=$(echo " • ${ENTRY}" | sed "s/|/\n • /g") - zenity --question --title="Optional Additions" --text="Confirm your selection of the following additions:\n${ADDITIONS_LIST}" --default-cancel --no-wrap + ADDITIONS_LIST=$(echo "${ENTRY}" | sed "s/|/\\\\n * /g" | sed "s/'//g") + dialog --keep-window --erase-on-exit --title "Chassis Type" --defaultno --yesno "Confirm your selection of the following additions:\n${ADDITIONS_LIST}" 0 0 then optional_additions="${ENTRY}" return 0 @@ -242,6 +264,7 @@ until prompt_optional_additions; do : ; done # Package operations echo "Setting up packages..." +sudo zypper --non-interactive in ${PATTERNS[@]} sudo zypper --non-interactive rm ${RM[@]} ${AL[@]} sudo zypper --non-interactive al ${AL[@]} sudo zypper --non-interactive in ${IN[@]} @@ -250,7 +273,7 @@ sudo zypper --non-interactive in ${IN[@]} # Flatpak operations echo "Setting up Flatpak remotes..." -FLATHUB_REMOTE=https://flathub.org/repo/flathub.flatpakrepo + sudo flatpak remote-add --if-not-exists flathub "${FLATHUB_REMOTE}" echo "Setting up Flatpak packages..." @@ -480,16 +503,19 @@ sudo chsh ${USER} -s $(which fish) echo "Installing scripts..." +# Clone personalizer repo containing scripts, desktop entries, etc. to temporary folder +git clone "${PERSONALIZER_REPO_URL}" "${PERSONALIZER_REPO_DIR}" + if [[ "${optional_additions}" != *'Touchpad Lock Toggle Shortcut'* ]]; then - rm ${SCRIPT_DIR}/scripts/gnome-toggle-touchpad-lock + rm ${PERSONALIZER_REPO_DIR}/scripts/gnome-toggle-touchpad-lock fi if [[ "${optional_additions}" != *'"Reboot to Windows" Launcher'* ]]; then - rm ${SCRIPT_DIR}/scripts/reboot-windows + rm ${PERSONALIZER_REPO_DIR}/scripts/reboot-windows fi -chmod +x ${SCRIPT_DIR}/scripts/* -sudo cp ${SCRIPT_DIR}/scripts/* /usr/bin +chmod +x ${PERSONALIZER_REPO_DIR}/scripts/* +sudo cp ${PERSONALIZER_REPO_DIR}/scripts/* /usr/bin ######################################## # Desktop entries @@ -497,11 +523,11 @@ sudo cp ${SCRIPT_DIR}/scripts/* /usr/bin echo "Installing desktop entries..." if [[ "${optional_additions}" != *'"Reboot to Windows" Launcher'* ]]; then - rm ${SCRIPT_DIR}/desktop_entries/windows.desktop + rm ${PERSONALIZER_REPO_DIR}/desktop_entries/windows.desktop fi mkdir -p ${HOME}/.local/share/applications/ -cp ${SCRIPT_DIR}/desktop-entries/* ${HOME}/.local/share/applications/ +cp ${PERSONALIZER_REPO_DIR}/desktop-entries/* ${HOME}/.local/share/applications/ ################################################################################ # @@ -509,17 +535,22 @@ cp ${SCRIPT_DIR}/desktop-entries/* ${HOME}/.local/share/applications/ # ################################################################################ -echo -echo "Personalization complete!" -echo -echo "Recommended next steps:" -echo " • Log in to Firefox Sync" -echo " • Configure Nextcloud client" -if [[ "${optional_additions}" == *"EasyEffects"* ]]; then - echo " • Install an audio device profile from" - echo " https://autoeq.app" -fi -echo " • Install a Wireguard VPN profile from" -echo " https://mullvad.net/en/account/#/wireguard-config/?platform=linux" -echo " • Configure display settings and run 'gdm-update-display-settings'" -echo " • Run 'themer' to install/update unofficial libadwaita themes" +echo " +Personalization complete! + +Recommended next steps: + + • Reboot + + • Log in to Firefox Sync + + • Configure Nextcloud client +$(if [[ "${optional_additions}" == *"EasyEffects"* ]]; then echo " • Install an audio device profile from\n https://autoeq.app\n"; fi) + • Install a Wireguard VPN profile from + https://mullvad.net/en/account/#/wireguard-config/?platform=linux + + • Configure display settings and run 'gdm-update-display-settings' + + • Run 'themer' to install/update unofficial libadwaita themes + +(A copy of these recommendations has been saved to ${HOME}/next-steps)" | tee ${HOME}/next-steps