#!/bin/bash
# Run on the phone as root (it needs internet, e.g. via Wi-Fi). Records exactly what was installed.
set -x
# This kernel has no Landlock, so pacman's download sandbox cannot start.
grep -q '^DisableSandbox' /etc/pacman.conf || sed -i '/^\[options\]/a DisableSandbox' /etc/pacman.conf
# We boot our own 6.16.4 kernel; never touch Arch's kernel or run its mkinitcpio hooks.
mkdir -p /etc/pacman.d/hooks; ln -sf /dev/null /etc/pacman.d/hooks/90-mkinitcpio-install.hook; ln -sf /dev/null /etc/pacman.d/hooks/60-mkinitcpio-remove.hook
pacman -Syu --noconfirm
# base: network, bluetooth, audio
pacman -S --noconfirm --needed sudo networkmanager wpa_supplicant bluez bluez-utils pulseaudio pulseaudio-alsa pulseaudio-bluetooth alsa-utils alsa-ucm-conf nano htop usbutils
# graphics: Mesa (Panfrost for the Mali-G76) and GNOME on Wayland
pacman -S --noconfirm --needed mesa mesa-utils vulkan-panfrost vulkan-tools \
  gnome-shell gdm gnome-session gnome-control-center gnome-terminal nautilus gnome-settings-daemon gnome-keyring \
  gnome-text-editor gnome-system-monitor gnome-tweaks gnome-backgrounds xdg-user-dirs xdg-desktop-portal-gnome \
  adwaita-icon-theme noto-fonts noto-fonts-emoji ttf-liberation firefox iio-sensor-proxy xorg-xwayland pipewire-jack \
  evolution-data-server rtkit python-evdev
systemctl enable NetworkManager bluetooth gdm rtkit-daemon systemd-networkd sshd begonia-keys
# per-user: PulseAudio + lingering so audio works without a login session
loginctl enable-linger user
runuser -u user -- env XDG_RUNTIME_DIR=/run/user/1000 systemctl --user enable pulseaudio.socket pulseaudio.service
# GNOME: power button does nothing (Vol Up + Power is the screenshot chord, see begonia-keys.py)
runuser -u user -- env XDG_RUNTIME_DIR=/run/user/1000 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
  gsettings set org.gnome.settings-daemon.plugins.power power-button-action 'nothing'
runuser -u user -- env XDG_RUNTIME_DIR=/run/user/1000 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
  gsettings set org.gnome.shell enabled-extensions "['appgrid-tuner@begonia']"
# Wi-Fi is configured per network: nmcli device wifi connect "<SSID>" password "<password>"
