40 lines
1.1 KiB
Bash
Executable File
40 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# run_once_30-install-power-mgmt.sh
|
|
# Laptop-only: power management stack. Skipped on desktop/server.
|
|
|
|
set -euo pipefail
|
|
|
|
SYS="$(chezmoi data --format=json 2>/dev/null | jq -r '.system // "desktop"')"
|
|
DISTRO_ID="$(chezmoi data --format=json 2>/dev/null | jq -r '.chezmoi.osRelease.id // empty')"
|
|
|
|
if [ "$SYS" != "laptop" ]; then
|
|
echo ">>> [power-mgmt] system=$SYS, skipping (not a laptop)"
|
|
exit 0
|
|
fi
|
|
|
|
case "$DISTRO_ID" in
|
|
arch)
|
|
echo ">>> [power-mgmt] arch"
|
|
sudo pacman -Syu --noconfirm --needed tlp auto-cpufreq power-profiles-daemon
|
|
sudo systemctl enable tlp
|
|
sudo systemctl enable auto-cpufreq
|
|
sudo systemctl enable power-profiles-daemon
|
|
;;
|
|
|
|
ubuntu)
|
|
echo ">>> [power-mgmt] ubuntu"
|
|
|
|
sudo apt-get install -y tlp tlp-rdw power-profiles-daemon
|
|
sudo systemctl enable tlp
|
|
# tlp and power-profiles-daemon conflict on most hardware — mask the latter
|
|
sudo systemctl mask power-profiles-daemon || true
|
|
;;
|
|
|
|
*)
|
|
echo ">>> [power-mgmt] unsupported distro: ${DISTRO_ID:-unknown}, skipping"
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
echo ">>> [power-mgmt] done"
|