fixes/after.sh
2026-10-14 15:10:02 +03:00

203 lines
No EOL
6.7 KiB
Bash

#!/bin/bash
set -e
#read -rp "Enter your username: " USERNAME
# Detect the normal user created by archinstall
USERNAME=$(awk -F: '$3 >= 1000 && $3 < 60000 && $6 ~ /^\/home\// {print $1; exit}' /etc/passwd)
# Error in case there is no normal user created
[[ -z "$USERNAME" ]] && { echo "Error: Could not detect the normal user."; exit 1; }
USER_HOME="/home/$USERNAME"
# ─────────────────────────────────────
# NO PASSWORD SETUP
# ─────────────────────────────────────
SUDOERS_FILE=/etc/sudoers.d/99-install-script
install -d -m 750 /etc/sudoers.d
printf '%s ALL=(ALL:ALL) NOPASSWD: ALL\n' "$USERNAME" > "$SUDOERS_FILE"
chmod 440 "$SUDOERS_FILE"
visudo -cf /etc/sudoers || exit 1
cleanup() {
rm -f "$SUDOERS_FILE"
visudo -c
}
trap cleanup EXIT
# ─────────────────────────────────────
# Misc
# ─────────────────────────────────────
# PACMAN LOVES CANDY
sed -i '/^# Misc options/a ILoveCandy' /etc/pacman.conf
# DISABLE KWALLETD
mkdir -p "$USER_HOME/.config"
cat > "$USER_HOME/.config/kwalletrc" <<'EOF'
[Wallet]
Enabled=false
EOF
# ENABLE DOLPHIN STORAGE INFO
kwriteconfig6 --file "$USER_HOME/.config/dolphinrc" --group General --key ShowStatusBar FullWidth
# CONFIGURE KEYBOARD LAYOUTS
cat > "$USER_HOME/.config/kxkbrc" <<'EOF'
[Layout]
DisplayNames=,
LayoutList=us,lt
Use=true
VariantList=,
EOF
# ─────────────────────────────────────
# Install yay
# ─────────────────────────────────────
install -d -o "$USERNAME" -g "$USERNAME" /home/tadas/.config/yay
#pacman -S --needed --noconfirm git base-devel
su - "$USERNAME" <<'EOF'
git clone https://aur.archlinux.org/yay-bin.git
cd yay-bin
makepkg -si --noconfirm
# Set up yay to not ask for password multiple times
#sudo mkdir -p ~/.config/yay
yay --sudoloop --save
# Instal AUR packages
yay -S --needed --noconfirm --removemake zsh-theme-powerlevel10k ttf-meslo-nerd-font-powerlevel10k coolercontrol-bin \
mangojuice-bin heroic-games-launcher-bin polymc-qt5-bin open-video-downloader-bin brave-bin onlyoffice-bin \
zenpower5-dkms-git zenergy-dkms-git game-devices-udev
EOF
# ─────────────────────────────────────
# Configure Konsole
# ─────────────────────────────────────
mkdir -p "$USER_HOME/.local/share/konsole"
cat > "$USER_HOME/.local/share/konsole/ZSH_Profile.profile" <<'EOF'
[Appearance]
Font=MesloLGS NF,10,-1,5,400,0,0,0,0,0,0,0,0,0,0,1,,0,0
[Cursor Options]
CursorShape=1
[General]
Name=ZSH Profile
Parent=FALLBACK/
[Terminal Features]
AnimatingCursorEnabled=true
BlinkingCursorEnabled=true
EOF
# Set the profile as default
kwriteconfig6 --file "$USER_HOME/.config/konsolerc" --group "Desktop Entry" --key "DefaultProfile" "ZSH_Profile.profile"
# ─────────────────────────────────────
# ZSH
# ─────────────────────────────────────
chsh -s /bin/zsh "$USERNAME"
cat > "$USER_HOME/.zshrc" <<'EOF'
# ─────────────────────────────────────
# Powerlevel10k
# ─────────────────────────────────────
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
# ─────────────────────────────────────
# Plugins
# ─────────────────────────────────────
# Autosuggestions
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# Syntax highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# ─────────────────────────────────────
# Powerlevel10k configuration
# ─────────────────────────────────────
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# ─────────────────────────────────────
# Completion
# ─────────────────────────────────────
autoload -Uz compinit
compinit
setopt CORRECT
setopt AUTO_CD
zstyle ':completion:*' completer _complete _approximate
zstyle ':completion:*' menu select
# ─────────────────────────────────────
# History
# ─────────────────────────────────────
HISTFILE="$HOME/.zsh_history"
SAVEHIST=10000
setopt APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
# ─────────────────────────────────────
# Manual to pdf
# ─────────────────────────────────────
manual() {
local pdf=$(mktemp --suffix=.pdf) || return 1
man -Tpdf "$1" > "$pdf" 2>/dev/null || { rm -f "$pdf"; echo "No manual entry for $1"; return 1; }
okular "$pdf"
rm -f "$pdf"
}
EOF
# Make everything we created belong to the user
chown -R "$USERNAME:$USERNAME" "$USER_HOME"
# ─────────────────────────────────────
# Grub
# ─────────────────────────────────────
# Enable windblows / other OS detection
sed -i 's/^#\?GRUB_DISABLE_OS_PROBER=.*/GRUB_DISABLE_OS_PROBER=false/' /etc/default/grub
#grub-mkconfig -o /boot/grub/grub.cfg
# ─────────────────────────────────────
# Install grub theme
# ─────────────────────────────────────
su - "$USERNAME" <<'EOF'
curl -O https://git.baltrust.eu.org/Baltrust/fixes/raw/branch/main/Graphite-grub2-theme.tar.xz
tar -xf Graphite-grub2-theme.tar.xz && rm Graphite-grub2-theme.tar.xz
cd grub2
./install.sh
cd "$OLDPWD"
EOF
rm after.sh
exit 0