Skip to content

Instantly share code, notes, and snippets.

@Speyll
Last active October 4, 2026 20:55
Show Gist options
  • Select an option

  • Save Speyll/009c93552dce1d8d09ed0907bb202c59 to your computer and use it in GitHub Desktop.

Select an option

Save Speyll/009c93552dce1d8d09ed0907bb202c59 to your computer and use it in GitHub Desktop.
Arch optimizations for the Thinkpad T14 Gen 5 Ryzen Edition
#!/usr/bin/env bash
# ThinkPad T14 Gen 5 (Ryzen) Post-Install Optimization Script for Arch Linux
set -euo pipefail
# Colors
G='\033[0;32m' Y='\033[1;33m' R='\033[0;31m' NC='\033[0m'
(( EUID == 0 )) || { echo -e "${R}Error: Must be run as root.${NC}"; exit 1; }
echo -e "${Y}==> Starting ThinkPad T14 Gen 5 Optimization...${NC}"
# 1. Packages
echo -e "${Y}[1/5] Installing packages...${NC}"
pacman -S --needed --noconfirm power-profiles-daemon zram-generator
# 2. Limine Bootloader Parameters
echo -e "${Y}[2/5] Configuring Limine bootloader...${NC}"
LIMINE_CONF=""
for path in \
/boot/limine.conf /boot/limine/limine.conf /boot/EFI/limine/limine.conf /boot/EFI/BOOT/limine.conf \
/efi/limine.conf /efi/limine/limine.conf /efi/EFI/limine/limine.conf /efi/EFI/BOOT/limine.conf; do
[[ -f "$path" ]] && { LIMINE_CONF="$path"; break; }
done
if [[ -n "$LIMINE_CONF" ]]; then
echo -e "${G}-> Found Limine config at: $LIMINE_CONF${NC}"
# Conditionally appends parameters only if 'amd_pstate=active' isn't already present on cmdline lines
sed -i -E '/cmdline:/ { /amd_pstate=active/! s/$/ amd_pstate=active acpi.ec_no_wakeup=1/ }' "$LIMINE_CONF"
else
echo -e "${R}Warning: limine.conf not found. Manually add 'amd_pstate=active acpi.ec_no_wakeup=1'.${NC}"
fi
# 3. Battery Thresholds (75%-80%)
echo -e "${Y}[3/5] Setting ThinkPad battery thresholds...${NC}"
UDEV_RULE="/etc/udev/rules.d/99-thinkpad-battery.rules"
if [[ ! -f "$UDEV_RULE" ]]; then
cat << 'EOF' > "$UDEV_RULE"
ACTION=="add", SUBSYSTEM=="power_supply", KERNEL=="BAT0", ATTR{charge_control_start_threshold}="75", ATTR{charge_control_end_threshold}="80"
EOF
udevadm control --reload-rules && udevadm trigger
fi
# 4. zRAM (zstd, 50% RAM)
echo -e "${Y}[4/5] Configuring zRAM...${NC}"
ZRAM_CONF="/etc/systemd/zram-generator.conf"
if [[ ! -f "$ZRAM_CONF" ]]; then
cat << 'EOF' > "$ZRAM_CONF"
[zram0]
zram-size = ram / 2
compression-algorithm = zstd
swap-priority = 100
fs-type = swap
EOF
systemctl daemon-reload
systemctl restart systemd-zram-setup@zram0.service || true
fi
# 5. Optimize Btrfs Mounts in fstab
echo -e "${Y}[5/5] Optimizing Btrfs mounts in /etc/fstab...${NC}"
# Appends compress=zstd:1 to any active btrfs entry lacking a compress option
sed -i -E '/\sbtrfs\s/ { /compress=/! s/(\sbtrfs\s+\S+)/\1,compress=zstd:1/ }' /etc/fstab
# 6. Enable Services
echo -e "${Y}==> Enabling system services...${NC}"
systemctl enable --now power-profiles-daemon
echo -e "${G}==> Optimization complete! Reboot to apply kernel parameters.${NC}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment