From f693c33310b15e83681ff85900c0de9aad4fb8fc Mon Sep 17 00:00:00 2001 From: Ryan Hughes <1630358+ryanrhughes@users.noreply.github.com> Date: Fri, 25 Jul 2025 19:20:17 -0400 Subject: [PATCH] Combine plymouth and login --- install/config/login.sh | 182 +++++++++++++++++++++++++++++++++---- install/config/plymouth.sh | 121 ------------------------ 2 files changed, 162 insertions(+), 141 deletions(-) delete mode 100755 install/config/plymouth.sh diff --git a/install/config/login.sh b/install/config/login.sh index b0e268d..774fa5e 100644 --- a/install/config/login.sh +++ b/install/config/login.sh @@ -1,13 +1,143 @@ #!/bin/bash -yay -S --noconfirm --needed uwsm +# Hyprland launched via UWSM and login directly as user, rely on disk encryption + hyprlock for security +if ! command -v uwsm &>/dev/null || ! command -v plymouth &>/dev/null; then + yay -S --noconfirm --needed uwsm plymouth +fi -# Compile the seamless login helper -- needed to prevent seeing terminal between loader and desktop -cat <<'CCODE' >/tmp/seamless-login.c +# ============================================================================== +# PLYMOUTH SETUP +# ============================================================================== + +if ! grep -Eq '^HOOKS=.*plymouth' /etc/mkinitcpio.conf; then + # Backup original mkinitcpio.conf just in case + backup_timestamp=$(date +"%Y%m%d%H%M%S") + sudo cp /etc/mkinitcpio.conf "/etc/mkinitcpio.conf.bak.${backup_timestamp}" + + # Add plymouth to HOOKS array after 'base udev' or 'base systemd' + if grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base systemd"; then + sudo sed -i '/^HOOKS=/s/base systemd/base systemd plymouth/' /etc/mkinitcpio.conf + elif grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base udev"; then + sudo sed -i '/^HOOKS=/s/base udev/base udev plymouth/' /etc/mkinitcpio.conf + else + echo "Couldn't add the Plymouth hook" + fi + + # Regenerate initramfs + sudo mkinitcpio -P +fi + +# Add kernel parameters for Plymouth +if [ -d "/boot/loader/entries" ]; then # systemd-boot + echo "Detected systemd-boot" + + for entry in /boot/loader/entries/*.conf; do + if [ -f "$entry" ]; then + # Skip fallback entries + if [[ "$(basename "$entry")" == *"fallback"* ]]; then + echo "Skipped: $(basename "$entry") (fallback entry)" + continue + fi + + # Skip if splash it already present for some reason + if ! grep -q "splash" "$entry"; then + sudo sed -i '/^options/ s/$/ splash quiet/' "$entry" + else + echo "Skipped: $(basename "$entry") (splash already present)" + fi + fi + done +elif [ -f "/etc/default/grub" ]; then # Grub + echo "Detected grub" + + # Backup GRUB config before modifying + backup_timestamp=$(date +"%Y%m%d%H%M%S") + sudo cp /etc/default/grub "/etc/default/grub.bak.${backup_timestamp}" + + # Check if splash is already in GRUB_CMDLINE_LINUX_DEFAULT + if ! grep -q "GRUB_CMDLINE_LINUX_DEFAULT.*splash" /etc/default/grub; then + # Get current GRUB_CMDLINE_LINUX_DEFAULT value + current_cmdline=$(grep "^GRUB_CMDLINE_LINUX_DEFAULT=" /etc/default/grub | cut -d'"' -f2) + + # Add splash and quiet if not present + new_cmdline="$current_cmdline" + if [[ ! "$current_cmdline" =~ splash ]]; then + new_cmdline="$new_cmdline splash" + fi + if [[ ! "$current_cmdline" =~ quiet ]]; then + new_cmdline="$new_cmdline quiet" + fi + + # Trim any leading/trailing spaces + new_cmdline=$(echo "$new_cmdline" | xargs) + + sudo sed -i "s/^GRUB_CMDLINE_LINUX_DEFAULT=\".*\"/GRUB_CMDLINE_LINUX_DEFAULT=\"$new_cmdline\"/" /etc/default/grub + + # Regenerate grub config + sudo grub-mkconfig -o /boot/grub/grub.cfg + else + echo "GRUB already configured with splash kernel parameters" + fi +elif [ -d "/etc/cmdline.d" ]; then # UKI + echo "Detected a UKI setup" + # Relying on mkinitcpio to assemble a UKI + # https://wiki.archlinux.org/title/Unified_kernel_image + if ! grep -q splash /etc/cmdline.d/*.conf; then + # Need splash, create the omarchy file + echo "splash" | sudo tee -a /etc/cmdline.d/omarchy.conf + fi + if ! grep -q quiet /etc/cmdline.d/*.conf; then + # Need quiet, create or append the omarchy file + echo "quiet" | sudo tee -a /etc/cmdline.d/omarchy.conf + fi +elif [ -f "/etc/kernel/cmdline" ]; then # UKI Alternate + # Alternate UKI kernel cmdline location + echo "Detected a UKI setup" + + # Backup kernel cmdline config before modifying + backup_timestamp=$(date +"%Y%m%d%H%M%S") + sudo cp /etc/kernel/cmdline "/etc/kernel/cmdline.bak.${backup_timestamp}" + + current_cmdline=$(cat /etc/kernel/cmdline) + + # Add splash and quiet if not present + new_cmdline="$current_cmdline" + if [[ ! "$current_cmdline" =~ splash ]]; then + new_cmdline="$new_cmdline splash" + fi + if [[ ! "$current_cmdline" =~ quiet ]]; then + new_cmdline="$new_cmdline quiet" + fi + + # Trim any leading/trailing spaces + new_cmdline=$(echo "$new_cmdline" | xargs) + + # Write new file + echo $new_cmdline | sudo tee /etc/kernel/cmdline +else + echo "" + echo " None of systemd-boot, GRUB, or UKI detected. Please manually add these kernel parameters:" + echo " - splash (to see the graphical splash screen)" + echo " - quiet (for silent boot)" + echo "" +fi + +if [ "$(plymouth-set-default-theme)" != "omarchy" ]; then + sudo cp -r "$HOME/.local/share/omarchy/default/plymouth" /usr/share/plymouth/themes/omarchy/ + sudo plymouth-set-default-theme -R omarchy +fi + +# ============================================================================== +# SEAMLESS LOGIN +# ============================================================================== + +if [ ! -x /usr/local/bin/seamless-login ]; then + # Compile the seamless login helper -- needed to prevent seeing terminal between loader and desktop + cat <<'CCODE' >/tmp/seamless-login.c /* - * Seamless Login - Minimal SDDM-style Plymouth transition - * Replicates SDDM's VT management for seamless auto-login - */ +* Seamless Login - Minimal SDDM-style Plymouth transition +* Replicates SDDM's VT management for seamless auto-login +*/ #include #include #include @@ -76,12 +206,14 @@ int main(int argc, char *argv[]) { } CCODE -gcc -o /tmp/seamless-login /tmp/seamless-login.c -sudo mv /tmp/seamless-login /usr/local/bin/seamless-login -sudo chmod +x /usr/local/bin/seamless-login -rm /tmp/seamless-login.c + gcc -o /tmp/seamless-login /tmp/seamless-login.c + sudo mv /tmp/seamless-login /usr/local/bin/seamless-login + sudo chmod +x /usr/local/bin/seamless-login + rm /tmp/seamless-login.c +fi -cat </dev/null; then - yay -S --noconfirm --needed plymouth - - # Skip if plymouth already exists for some reason - # Backup original mkinitcpio.conf just in case - backup_timestamp=$(date +"%Y%m%d%H%M%S") - sudo cp /etc/mkinitcpio.conf "/etc/mkinitcpio.conf.bak.${backup_timestamp}" - - # Add plymouth to HOOKS array after 'base udev' or 'base systemd' - if grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base systemd"; then - sudo sed -i '/^HOOKS=/s/base systemd/base systemd plymouth/' /etc/mkinitcpio.conf - elif grep "^HOOKS=" /etc/mkinitcpio.conf | grep -q "base udev"; then - sudo sed -i '/^HOOKS=/s/base udev/base udev plymouth/' /etc/mkinitcpio.conf - else - echo "Couldn't add the Plymouth hook" - fi - - # Regenerate initramfs - sudo mkinitcpio -P - - # Add kernel parameters for Plymouth (systemd-boot only) - if [ -d "/boot/loader/entries" ]; then - echo "Detected systemd-boot" - - for entry in /boot/loader/entries/*.conf; do - if [ -f "$entry" ]; then - # Skip fallback entries - if [[ "$(basename "$entry")" == *"fallback"* ]]; then - echo "Skipped: $(basename "$entry") (fallback entry)" - continue - fi - - # Skip if splash it already present for some reason - if ! grep -q "splash" "$entry"; then - sudo sed -i '/^options/ s/$/ splash quiet/' "$entry" - else - echo "Skipped: $(basename "$entry") (splash already present)" - fi - fi - done - elif [ -f "/etc/default/grub" ]; then - echo "Detected grub" - # Backup GRUB config before modifying - backup_timestamp=$(date +"%Y%m%d%H%M%S") - sudo cp /etc/default/grub "/etc/default/grub.bak.${backup_timestamp}" - - # Check if splash is already in GRUB_CMDLINE_LINUX_DEFAULT - if ! grep -q "GRUB_CMDLINE_LINUX_DEFAULT.*splash" /etc/default/grub; then - # Get current GRUB_CMDLINE_LINUX_DEFAULT value - current_cmdline=$(grep "^GRUB_CMDLINE_LINUX_DEFAULT=" /etc/default/grub | cut -d'"' -f2) - - # Add splash and quiet if not present - new_cmdline="$current_cmdline" - if [[ ! "$current_cmdline" =~ splash ]]; then - new_cmdline="$new_cmdline splash" - fi - if [[ ! "$current_cmdline" =~ quiet ]]; then - new_cmdline="$new_cmdline quiet" - fi - - # Trim any leading/trailing spaces - new_cmdline=$(echo "$new_cmdline" | xargs) - - sudo sed -i "s/^GRUB_CMDLINE_LINUX_DEFAULT=\".*\"/GRUB_CMDLINE_LINUX_DEFAULT=\"$new_cmdline\"/" /etc/default/grub - - # Regenerate grub config - sudo grub-mkconfig -o /boot/grub/grub.cfg - else - echo "GRUB already configured with splash kernel parameters" - fi - elif [ -d "/etc/cmdline.d" ]; then - echo "Detected a UKI setup" - # Relying on mkinitcpio to assemble a UKI - # https://wiki.archlinux.org/title/Unified_kernel_image - if ! grep -q splash /etc/cmdline.d/*.conf; then - # Need splash, create the omarchy file - echo "splash" | sudo tee -a /etc/cmdline.d/omarchy.conf - fi - if ! grep -q quiet /etc/cmdline.d/*.conf; then - # Need quiet, create or append the omarchy file - echo "quiet" | sudo tee -a /etc/cmdline.d/omarchy.conf - fi - elif [ -f "/etc/kernel/cmdline" ]; then - # Alternate UKI kernel cmdline location - echo "Detected a UKI setup" - - # Backup kernel cmdline config before modifying - backup_timestamp=$(date +"%Y%m%d%H%M%S") - sudo cp /etc/kernel/cmdline "/etc/kernel/cmdline.bak.${backup_timestamp}" - - current_cmdline=$(cat /etc/kernel/cmdline) - - # Add splash and quiet if not present - new_cmdline="$current_cmdline" - if [[ ! "$current_cmdline" =~ splash ]]; then - new_cmdline="$new_cmdline splash" - fi - if [[ ! "$current_cmdline" =~ quiet ]]; then - new_cmdline="$new_cmdline quiet" - fi - - # Trim any leading/trailing spaces - new_cmdline=$(echo "$new_cmdline" | xargs) - - # Write new file - echo $new_cmdline | sudo tee /etc/kernel/cmdline - else - echo "" - echo "Neither systemd-boot nor GRUB detected. Please manually add these kernel parameters:" - echo " - splash (to see the graphical splash screen)" - echo " - quiet (for silent boot)" - echo "" - fi - - # Copy and set the Plymouth theme - sudo cp -r "$HOME/.local/share/omarchy/default/plymouth" /usr/share/plymouth/themes/omarchy/ - - sudo plymouth-set-default-theme -R omarchy -fi