Compare commits

...

5 Commits

Author SHA1 Message Date
9d26f04af6 Add transform script for existing Arch+Wayland systems
Extract shared helpers into lib.sh (log, err, confirm, path constants)
and refactor post-install.sh + update.sh to source it.

New transform.sh converts an existing Arch+Wayland system to Moonarch:
pre-flight summary, config backup, DM conflict resolution, PulseAudio
removal, full package install, and hard overwrite of all configs.

Also migrate kanshi from niri spawn-at-startup to systemd user service.
2026-03-29 15:03:44 +02:00
24d70db2cf fix: migrate swww to awww, add per-user GTK4 symlinks
swww was renamed to awww (codeberg.org/LGFae/awww). Update package
list, README references, and add compatibility symlinks in post-install
so waypaper keeps working until it supports awww natively.

Also add per-user ~/.config/gtk-4.0/ symlinks — libadwaita ignores the
system-wide /etc/xdg/ fallback, so apps like Nautilus need user-level
CSS links to pick up the Catppuccin theme.
2026-03-29 14:14:06 +02:00
d873985930 fix icon theme references, replace Newaita with Colloid-Catppuccin
- Update gtk-3.0/settings.ini icon theme to match gsettings
- Replace hardcoded Newaita icon path in moonarch-btnote with
  generic icon name (uses active theme automatically)
- Update README to reflect correct icon theme
2026-03-29 14:10:54 +02:00
eaf30724aa fix missing packages, remove dead code, replace ponymix with pactl
- Add wl-clipboard, libnotify, upower, bluez, bluez-utils to official.txt
- Remove stow (installed but never used)
- Remove dead moonlock.service cp block from post-install.sh
- Rewrite moonarch-sink-switcher and moonarch-volume to use pactl
  instead of ponymix (already available via libpulse)
2026-03-29 14:00:51 +02:00
541b701773 add kanshi for dynamic output management, fix wdisplays package
- Add kanshi to official package list and spawn at niri startup
- Add empty default kanshi config in defaults/xdg/kanshi/
- Replace wdisplays-git with wdisplays-persistent-gettext in AUR list
2026-03-29 13:46:53 +02:00
14 changed files with 704 additions and 119 deletions

256
README.md
View File

@ -1,65 +1,239 @@
# Moonarch
Reproducible Arch Linux setup with Niri (Wayland compositor), greetd/moongreet, Catppuccin Mocha theming and full automation.
Reproducible Arch Linux desktop environment — fully automated from bare metal to a
configured Niri (scrollable tiling Wayland) system with Catppuccin Mocha theming.
Moonarch combines archinstall for the base system with post-install automation that
handles packages, XDG defaults, system services, greeter, idle management, and a
suite of rofi-based helper tools. The result is a complete development/productivity
desktop that can be rebuilt from scratch in minutes.
## Why These Choices
| Component | Choice | Why |
|-----------|--------|-----|
| **Compositor** | [Niri](https://github.com/YaLTeR/niri) | Scrollable tiling — no fixed grid, infinite horizontal workspace. Purpose-built Wayland compositor, not an X11 port. |
| **Greeter** | [greetd](https://sr.ht/~kennylevinsen/greetd/) + [moongreet](https://gitea.moonarch.de/nevaforget/moongreet) | Minimal, Wayland-native login. moongreet provides GTK4 UI with fingerprint support, running inside its own Niri instance. |
| **Lock Screen** | [moonlock](https://gitea.moonarch.de/nevaforget/moonlock) | ext-session-lock-v1 protocol — compositor guarantees lock on crash. PAM + fprintd, GPU blur, multi-monitor. |
| **Power Menu** | [moonset](https://gitea.moonarch.de/nevaforget/moonset) | GTK4 Layer Shell overlay above Waybar. Lock, logout, hibernate, reboot, shutdown with confirmation. |
| **Idle Manager** | [stasis](https://aur.archlinux.org/packages/stasis) | Separate AC/battery power plans. Brightness dimming, DPMS, lock (via moonlock), and suspend on configurable timeouts. |
| **Bar** | [Waybar](https://github.com/Alexays/Waybar) | Wayland-native, highly customizable. Niri workspace/window modules via community plugins. |
| **Launcher** | [Rofi](https://github.com/lbonn/rofi) (lbonn Wayland fork) | Versatile dmenu replacement. Powers app launcher, clipboard, bluetooth, volume, VPN, CPU governor, and session menus. |
| **Terminal** | [Foot](https://codeberg.org/dnkl/foot) | Fast, minimal Wayland-native terminal. Server mode for instant window spawning. |
| **Shell** | Zsh | Programmable completion, FZF integration, syntax highlighting. |
| **Audio** | PipeWire | Drop-in replacement for PulseAudio/JACK with lower latency. RNNoise input denoising configured out of the box. |
| **Display Management** | [kanshi](https://sr.ht/~emersion/kanshi/) + [wdisplays](https://github.com/artizirk/wdisplays) | kanshi auto-switches output profiles on hotplug. wdisplays for manual GUI configuration. |
| **Notifications** | [dunst](https://dunst-project.org/) | Lightweight, scriptable. DND mode exposed as Waybar module. |
| **Clipboard** | [cliphist](https://github.com/sentriz/cliphist) + wl-clipboard | Text and image history. Rofi frontend for selection, wl-paste watches the clipboard. |
| **Theme** | Catppuccin Mocha | Consistent dark palette across GTK, terminal, bar, rofi, notifications, and lock screen. |
| **Icons** | Colloid-Grey-Catppuccin-Dark | Catppuccin-colored icon set matching the GTK theme. |
| **Cursor** | Sweet-cursors | Visible on dark backgrounds without clashing. |
| **Font** | UbuntuSans Nerd Font | Clean sans-serif with full Nerd Font glyph coverage for bar/terminal icons. |
| **Wallpaper** | [waypaper](https://github.com/anufrievroman/waypaper) + [awww](https://codeberg.org/LGFae/awww) | waypaper provides GUI selection, awww handles animated transitions (60 FPS, 2s crossfade). |
| **Firewall** | UFW | Simple deny-incoming/allow-outgoing default. Sane baseline without iptables complexity. |
| **AUR Helper** | [paru](https://github.com/Morganamilo/paru) | Rust-based, pacman-compatible. Supports custom PKGBUILD repos for moongreet/moonlock/moonset. |
## Quick Start
### Option A: Download config in the live system
### Fresh Install (Bare Metal)
1. Flash the [Arch ISO](https://archlinux.org/download/) to USB and boot from it
2. In the live system:
1. Boot the [Arch ISO](https://archlinux.org/download/) and download the config:
```bash
curl -O https://gitea.moonarch.de/nevaforget/moonarch/raw/branch/main/config/user_configuration.json
archinstall --config user_configuration.json
```
3. Choose disk + kernel interactively, the rest comes from the config
### Option B: Place config on USB stick (Ventoy)
1. Install [Ventoy](https://www.ventoy.net/) on USB
2. Copy the Arch ISO and `user_configuration.json` to the Ventoy partition
3. Boot from it, then:
```bash
archinstall --config /run/media/ventoy/user_configuration.json
```
### After archinstall
1. Reboot — the repo is already in `/opt/moonarch` (via custom-commands)
2. Log in, then:
2. Choose disk and kernel interactively — everything else comes from the config.
3. Reboot, log in, then:
```bash
/opt/moonarch/scripts/post-install.sh
```
3. Reboot again — done
4. Reboot again — done.
## Structure
The archinstall config clones this repo to `/opt/moonarch` via custom-commands.
post-install.sh handles the remaining ~100 packages, all configs, themes, services,
and user setup.
```
config/ archinstall configuration
packages/ Package lists (official.txt + aur.txt)
scripts/ Post-install, update, theme installer
defaults/
bin/ moonarch-* helper scripts (/usr/local/bin/)
xdg/ XDG defaults (/etc/xdg/)
shell/ Zsh configuration
etc/ greetd + moongreet configuration
backgrounds/ Default wallpaper
### Transform (Existing Arch+Wayland System)
Already running Arch with a Wayland compositor (Sway, Hyprland, GNOME Wayland, etc.)?
Transform converts your system to Moonarch without reinstalling.
**Prerequisites:** Active Wayland session, git installed.
```bash
git clone https://gitea.moonarch.de/nevaforget/moonarch.git /opt/moonarch
/opt/moonarch/scripts/transform.sh
```
## Update
The script will:
1. Show a pre-flight summary of all changes
2. Back up your `~/.config/`, `~/.zshrc`, and `/etc/xdg/` to timestamped tar archives
3. Disable conflicting display managers (SDDM, GDM, LightDM, etc.)
4. Remove conflicting packages (e.g. PulseAudio → PipeWire)
5. Install all Moonarch packages and configs (**hard overwrite** of all user configs)
6. Enable greetd, firewall, and system services
After completion, **reboot** (do not log out — your previous DM is already disabled).
### Update
```bash
moonarch-update
```
Updates repo, system packages, missing packages and defaults — all interactive with confirmations.
Interactive updater that syncs the repo, upgrades system/AUR packages, reconciles
package lists against what's installed, deploys changed XDG defaults, and cleans
orphaned packages.
## Stack
## Project Structure
- **Compositor:** Niri (Scrollable Tiling Wayland)
- **Greeter:** greetd + moongreet
- **Bar:** Waybar
- **Launcher:** Rofi (lbonn Wayland Fork)
- **Terminal:** Foot
- **Theme:** Catppuccin Mocha + Sweet Cursors + Newaita Icons
- **Shell:** Zsh
```
config/
user_configuration.json archinstall config (locale, audio, services, custom-commands)
packages/
official.txt Arch repo packages (~100), one per line
aur.txt AUR packages (~15), one per line
scripts/
lib.sh Shared helpers sourced by all scripts
post-install.sh Main automation (packages, configs, themes, services)
transform.sh Convert existing Arch+Wayland system to Moonarch
install-themes.sh Cursor theme installer (Sweet-cursors)
update.sh System updater (symlinked to moonarch-update)
defaults/
xdg/ System-wide XDG configs (deployed to /etc/xdg/)
niri/config.kdl Compositor: layout, keybinds, startup apps
waybar/config, style.css Bar: modules, layout, Catppuccin styling
rofi/config.rasi, themes/ Launcher: config + 8 applet themes
foot/foot.ini Terminal: font, colors, keybinds
dunst/dunstrc Notifications: geometry, colors, behavior
kanshi/config Display profiles (empty, user-configured)
gtklock/ Lock screen: config, UI layout, CSS
stasis/stasis.rune Idle manager: AC/battery power plans
pipewire/ Audio: RNNoise input denoising
waypaper/config.ini Wallpaper manager: backend, folder, transitions
fastfetch/config.jsonc System info display
gtk-3.0/, gtk-4.0/ GTK theme settings
bin/ Helper scripts (deployed to /usr/local/bin/)
moonarch-launcher App launcher (rofi drun/run/filebrowser/window)
moonarch-clipboard Clipboard history browser (rofi + cliphist)
moonarch-bluetooth Bluetooth device manager (rofi + bluetoothctl)
moonarch-volume Volume control applet (rofi + amixer/pactl)
moonarch-sink-switcher Audio output switcher (rofi + pactl)
moonarch-vpn VPN connection manager (rofi + nmcli)
moonarch-cpugov CPU governor switcher (rofi + auto-cpufreq)
moonarch-session Session menu (rofi: lock/logout/suspend/reboot/shutdown)
moonarch-setmen Settings menu launcher (rofi script mode)
moonarch-dnd Dunst Do Not Disturb toggle (Waybar JSON output)
moonarch-btnote Bluetooth device battery monitor (upower + notify-send)
moonarch-capsnote Caps Lock toggle notification
moonarch-waybar-cpugov Waybar module: CPU governor status
moonarch-waybar-gpustat Waybar module: GPU utilization
moonarch-waybar-hidpp Waybar module: Logitech HID++ device battery
shell/zshrc Zsh config: prompt, aliases, FZF, completion
etc/greetd/ greetd daemon + greeter Niri config
etc/moongreet/ moongreet configuration
user/systemd/user/ Systemd user services (kanshi)
user/waybar/ Per-user Waybar overrides (only copied if missing)
backgrounds/wallpaper.jpg Default wallpaper (shared by desktop, greeter, lock screen)
```
## Startup Sequence
```
greetd ─► niri (greeter instance) ─► moongreet ─► user authenticates
niri (user session)
┌──────────┬────────┬────────┬──────────┐
▼ ▼ ▼ ▼ ▼
waybar dunst foot waypaper cliphist
(bar) (notify) (server) (wallpaper) (clipboard)
kanshi runs as a systemd user service (graphical-session.target)
```
## Keybinds (Default)
| Key | Action |
|-----|--------|
| `Super+Return` | Open terminal (foot) |
| `Super+Space` | App launcher (rofi) |
| `Super+Q` | Close window |
| `Super+O` / `Super+Tab` | Overview |
| `Super+F` | Maximize column |
| `Super+Shift+F` | Fullscreen window |
| `Super+V` | Toggle floating |
| `Super+H/J/K/L` | Focus left/down/up/right |
| `Super+Ctrl+H/J/K/L` | Move window |
| `Super+Shift+H/J/K/L` | Focus monitor |
| `Super+1-9` | Switch workspace |
| `Super+C` | Clipboard history |
| `Super+E` | File manager |
| `Super+A` | Volume control |
| `Super+T` | Settings menu |
| `Super+N` | VPN manager |
| `Super+Alt+L` | Session menu (wlogout) |
| `Print` | Screenshot |
| `Ctrl+Print` | Screenshot screen |
| `Alt+Print` | Screenshot window |
## Customization
All system configs live in `/etc/xdg/` and can be overridden per-user in `~/.config/`:
| Component | System Default | User Override |
|-----------|---------------|---------------|
| Niri | `/etc/xdg/niri/config.kdl` | `~/.config/niri/config.kdl` |
| Waybar | `/etc/xdg/waybar/` | `~/.config/waybar/` |
| Rofi | `/etc/xdg/rofi/` | `~/.config/rofi/` |
| Foot | `/etc/xdg/foot/foot.ini` | `~/.config/foot/foot.ini` |
| Dunst | `/etc/xdg/dunst/dunstrc` | `~/.config/dunst/dunstrc` |
| kanshi | `/etc/xdg/kanshi/config` | `~/.config/kanshi/config` |
| PipeWire | `/etc/xdg/pipewire/` | `~/.config/pipewire/` |
| Zsh | `/etc/zsh/zshrc.moonarch` | `~/.zshrc` + `~/.zshrc.d/` |
Helper scripts in `/usr/local/bin/moonarch-*` are not meant to be overridden — they
are part of the system and updated via `moonarch-update`.
## System Services
| Service | Purpose |
|---------|---------|
| greetd | Login greeter (runs moongreet inside Niri) |
| NetworkManager | Network management (WiFi, VPN, Ethernet) |
| bluetooth | Bluetooth stack (bluez) |
| docker | Container runtime |
| systemd-timesyncd | NTP time synchronization |
| ufw | Firewall (deny incoming, allow outgoing) |
| auto-cpufreq | CPU frequency scaling (AC: performance, battery: powersave) |
### User Services (systemd --user)
| Service | Purpose |
|---------|---------|
| kanshi | Dynamic display configuration (auto-switch output profiles on hotplug) |
## Moonarch Ecosystem
Moonarch is the deployment and configuration layer. Three companion projects provide
the Wayland session UI — all built with Rust + gtk4-rs and sharing Catppuccin Mocha
theming:
| Project | Role | Installed via |
|---------|------|---------------|
| [moongreet](https://gitea.moonarch.de/nevaforget/moongreet) | greetd greeter (GTK4 Layer Shell, fingerprint, i18n) | `paru -S moongreet-git` |
| [moonlock](https://gitea.moonarch.de/nevaforget/moonlock) | Wayland lock screen (ext-session-lock-v1, PAM, fprintd) | `paru -S moonlock-git` |
| [moonset](https://gitea.moonarch.de/nevaforget/moonset) | Power menu overlay (GTK4 Layer Shell) | `paru -S moonset-git` |
These are built from a [custom paru package repository](https://gitea.moonarch.de/nevaforget/moonarch-pkgbuilds)
added during post-install.
## License
MIT

View File

@ -3,7 +3,7 @@
# ABOUTME: Can be run periodically via timer or cron.
NOTIFY_AT_PERCENTAGE=70
ICON="/usr/share/icons/Newaita-reborn/status/symbolic/battery-empty-symbolic.svg"
ICON="battery-empty"
for d in $(upower -e); do
DEVICE_DATA=$(upower -i "$d")

View File

@ -1,16 +1,13 @@
#!/usr/bin/bash
# ABOUTME: Rofi-based PulseAudio sink switcher using ponymix.
# ABOUTME: Rofi-based PulseAudio sink switcher using pactl.
# ABOUTME: Changes the default sink and moves all active streams to it.
# choose pulseaudio sink via rofi or dmenu
# choose audio sink via rofi
# changes default sink and moves all streams to that sink
#https://gist.github.com/Nervengift/844a597104631c36513c?permalink_comment_id=1826282
sink=$(ponymix -t sink list|awk '/^sink/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}'|rofi -dmenu -theme '/etc/xdg/rofi/themes/volume.rasi' -mesg '󱡫 Sink Switcher' -p 'pulseaudio sink:' -location 6 -width 100|grep -Po '[0-9]+(?=:)') &&
sink=$(pactl list sinks short | awk '{print $1, $2}' | rofi -dmenu -theme '/etc/xdg/rofi/themes/volume.rasi' -mesg '󱡫 Sink Switcher' -p 'audio sink:' -location 6 -width 100 | awk '{print $1}') &&
ponymix set-default -d $sink &&
for input in $(ponymix list -t sink-input|grep -Po '[0-9]+(?=:)');do
echo "$input -> $sink"
ponymix -t sink-input -d $input move $sink
pactl set-default-sink "$sink" &&
for input in $(pactl list sink-inputs short | awk '{print $1}'); do
pactl move-sink-input "$input" "$sink"
done

View File

@ -41,8 +41,8 @@ else
micon=''
fi
currentsink=$(ponymix defaults|awk '/^sink/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}' | cut -d':' -f2)
currentsource=$(ponymix defaults|awk '/^source/ {s=$1" "$2;getline;gsub(/^ +/,"",$0);print s" "$0}' | cut -d':' -f2)
currentsink=$(pactl get-default-sink)
currentsource=$(pactl get-default-source)
# Theme Elements

View File

@ -0,0 +1,17 @@
# ABOUTME: systemd user service for kanshi dynamic display configuration.
# ABOUTME: Starts kanshi as part of the graphical session, with automatic restart.
[Unit]
Description=Dynamic display configuration
Documentation=man:kanshi(1)
PartOf=graphical-session.target
After=graphical-session.target
[Service]
Type=simple
ExecStart=/usr/bin/kanshi
Restart=on-failure
RestartSec=3
[Install]
WantedBy=graphical-session.target

View File

@ -3,7 +3,7 @@
[Settings]
gtk-theme-name=Colloid-Catppuccin
gtk-icon-theme-name=Newaita-reborn-gray-dark
gtk-icon-theme-name=Colloid-Grey-Catppuccin-Dark
gtk-font-name=UbuntuSans Nerd Font 11
gtk-cursor-theme-name=Sweet-cursors
gtk-cursor-theme-size=24

View File

@ -0,0 +1,2 @@
# ABOUTME: kanshi configuration for dynamic display output management.
# ABOUTME: Add profiles here to auto-switch outputs on hotplug events.

View File

@ -77,6 +77,7 @@ layout {
}
// xwayland-satellite is managed automatically since niri 25.08
// kanshi is managed via systemd user service (kanshi.service)
spawn-at-startup "waybar"
spawn-at-startup "dunst"
spawn-at-startup "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"

View File

@ -13,7 +13,7 @@ rofi-lbonn-wayland-git
waybar-niri-windows-bin
waybar-niri-workspaces-enhanced-git
waypaper
wdisplays-git
wdisplays-persistent-gettext
wl-color-picker
wlogout
gtklock-dpms-module

View File

@ -36,6 +36,10 @@ sshfs
nmap
wget
# Bluetooth
bluez
bluez-utils
# Audio (PipeWire)
pipewire
pipewire-alsa
@ -49,13 +53,17 @@ pavucontrol
# Wayland / Niri
niri
kanshi
xwayland-satellite
# Desktop Utilities
waybar
dunst
cliphist
swww
wl-clipboard
libnotify
upower
awww
brightnessctl
gtklock
gtklock-playerctl-module
@ -89,7 +97,6 @@ go
neovim
npm
rustup
stow
# System
docker

45
scripts/lib.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# ABOUTME: Shared helper functions and constants for Moonarch scripts.
# ABOUTME: Sourced by post-install.sh, update.sh and transform.sh.
# Path constants — BASH_SOURCE[1] resolves to the calling script, not lib.sh itself.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
OFFICIAL_PACKAGES="$PROJECT_DIR/packages/official.txt"
AUR_PACKAGES="$PROJECT_DIR/packages/aur.txt"
DEFAULTS_DIR="$PROJECT_DIR/defaults"
# --- Helper functions ---
log() {
echo -e "\e[1;34m[Moonarch]\e[0m $*"
}
err() {
echo -e "\e[1;31m[Moonarch ERROR]\e[0m $*" >&2
}
read_packages() {
grep -v '^\s*#' "$1" | grep -v '^\s*$'
}
confirm() {
read -r -p "$1 [y/N] " response
[[ "$response" =~ ^[yY]$ ]]
}
# --- Prerequisite checks ---
check_not_root() {
if [[ $EUID -eq 0 ]]; then
err "Do NOT run as root. The script uses sudo where needed."
exit 1
fi
}
check_pacman() {
if ! command -v pacman &>/dev/null; then
err "pacman not found — is this really Arch Linux?"
exit 1
fi
}

View File

@ -4,37 +4,12 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
OFFICIAL_PACKAGES="$PROJECT_DIR/packages/official.txt"
AUR_PACKAGES="$PROJECT_DIR/packages/aur.txt"
DEFAULTS_DIR="$PROJECT_DIR/defaults"
# --- Helper functions ---
log() {
echo -e "\e[1;34m[Moonarch]\e[0m $*"
}
err() {
echo -e "\e[1;31m[Moonarch ERROR]\e[0m $*" >&2
}
read_packages() {
grep -v '^\s*#' "$1" | grep -v '^\s*$'
}
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh"
# --- Prerequisites ---
if [[ $EUID -eq 0 ]]; then
err "Do NOT run as root. The script uses sudo where needed."
exit 1
fi
if ! command -v pacman &>/dev/null; then
err "pacman not found — is this really Arch Linux?"
exit 1
fi
check_not_root
check_pacman
# --- Install official packages ---
@ -117,6 +92,14 @@ if [[ -d "$THEME_GTK4" ]]; then
# Assets symlink: remove first if exists (ln -sf on directories follows the link)
sudo rm -f "$GTK4_XDG/assets"
sudo ln -s "$THEME_GTK4/assets" "$GTK4_XDG/assets"
# libadwaita only reads user CSS from ~/.config/gtk-4.0/, not /etc/xdg/ fallback.
# Create per-user symlinks so the theme applies to libadwaita apps (e.g. Nautilus).
USER_GTK4="$HOME/.config/gtk-4.0"
mkdir -p "$USER_GTK4"
ln -sf "$THEME_GTK4/gtk-dark.css" "$USER_GTK4/gtk.css"
ln -sf "$THEME_GTK4/gtk-dark.css" "$USER_GTK4/gtk-dark.css"
rm -f "$USER_GTK4/assets"
ln -s "$THEME_GTK4/assets" "$USER_GTK4/assets"
else
err "GTK4 theme not found: $THEME_GTK4 — libadwaita apps will use fallback theme."
fi
@ -134,6 +117,14 @@ gsettings set org.gnome.desktop.interface font-name 'UbuntuSans Nerd Font 11'
log "Installing Moonarch helper scripts to /usr/local/bin/..."
sudo install -m 755 "$DEFAULTS_DIR/bin/moonarch-"* /usr/local/bin/
# --- awww compatibility symlinks (waypaper still calls swww) ---
if command -v awww &>/dev/null && ! command -v swww &>/dev/null; then
log "Creating swww -> awww compatibility symlinks..."
sudo ln -s /usr/bin/awww /usr/local/bin/swww
sudo ln -s /usr/bin/awww-daemon /usr/local/bin/swww-daemon
fi
# --- Zsh configuration ---
log "Installing Zsh default config..."
@ -154,12 +145,6 @@ if [[ ! -f "$HOME/.zshrc" ]]; then
echo "source /etc/zsh/zshrc.moonarch" >> "$HOME/.zshrc"
fi
# --- moonlock systemd user service ---
log "Configuring moonlock user service..."
sudo mkdir -p /etc/systemd/user
sudo cp "$DEFAULTS_DIR/etc/systemd/user/moonlock.service" /etc/systemd/user/moonlock.service
# --- greetd / moongreet configuration ---
log "Configuring greetd + moongreet..."
@ -241,6 +226,22 @@ if [[ -d "$USER_DEFAULTS_DIR" ]]; then
done
fi
# --- Enable systemd user services ---
log "Enabling systemd user services..."
USER_SERVICES=(
"kanshi"
)
for service in "${USER_SERVICES[@]}"; do
if systemctl --user list-unit-files "${service}.service" &>/dev/null; then
systemctl --user enable "$service"
log " + $service (user)"
else
log " ~ $service (user) not found, skipped."
fi
done
# --- Screenshots directory ---
mkdir -p "$HOME/Pictures/Screenshots"

367
scripts/transform.sh Executable file
View File

@ -0,0 +1,367 @@
#!/bin/bash
# ABOUTME: Transforms an existing Arch+Wayland system into a Moonarch system.
# ABOUTME: Backs up configs, installs packages, deploys all defaults with hard overwrite.
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh"
# ============================================================
# Phase 1: Prerequisites & Detection
# ============================================================
check_not_root
check_pacman
# Require active Wayland session
if [[ "${XDG_SESSION_TYPE:-}" != "wayland" ]] && [[ -z "${WAYLAND_DISPLAY:-}" ]]; then
err "No active Wayland session detected. Transform requires Wayland."
exit 1
fi
# Detect conflicting display managers
CONFLICTING_DMS=()
for dm in sddm gdm lightdm ly lemurs; do
if systemctl is-enabled "${dm}.service" &>/dev/null; then
CONFLICTING_DMS+=("$dm")
fi
done
# Detect conflicting packages
CONFLICTING_PKGS=()
if pacman -Qq pulseaudio &>/dev/null && ! pacman -Qq pipewire-pulse &>/dev/null; then
CONFLICTING_PKGS+=("pulseaudio")
fi
# ============================================================
# Phase 2: Pre-flight Summary
# ============================================================
echo ""
log "============================================"
log " Moonarch Transform — Pre-flight Summary"
log "============================================"
echo ""
log "Wayland session: detected"
if [[ ${#CONFLICTING_DMS[@]} -gt 0 ]]; then
log "Display managers: ${CONFLICTING_DMS[*]} (will be disabled)"
else
log "Display managers: none conflicting"
fi
if [[ ${#CONFLICTING_PKGS[@]} -gt 0 ]]; then
log "Package conflicts: ${CONFLICTING_PKGS[*]} (will be removed)"
else
log "Package conflicts: none"
fi
echo ""
log "Actions:"
log " 1. Backup ~/.config/, ~/.zshrc, /etc/xdg/ to ~/moonarch-backup-<ts>.tar.gz"
log " 2. Install official + AUR packages"
log " 3. Disable conflicting DMs, enable greetd"
log " 4. Overwrite ALL system configs (/etc/xdg/, /etc/greetd/, ...)"
log " 5. Overwrite ALL user configs (~/.config/)"
log " 6. Configure zsh, GTK themes, firewall, services"
echo ""
err "This will REPLACE your current desktop configuration."
echo ""
if ! confirm "Proceed?"; then
log "Transform cancelled."
exit 0
fi
# ============================================================
# Phase 3: Backup
# ============================================================
BACKUP_FILE="$HOME/moonarch-backup-$(date +%Y%m%d-%H%M%S).tar.gz"
log "Creating backup: $BACKUP_FILE"
# Build list of paths that actually exist
BACKUP_PATHS=()
[[ -d "$HOME/.config" ]] && BACKUP_PATHS+=(".config")
[[ -f "$HOME/.zshrc" ]] && BACKUP_PATHS+=(".zshrc")
[[ -d "$HOME/.zshrc.d" ]] && BACKUP_PATHS+=(".zshrc.d")
if [[ ${#BACKUP_PATHS[@]} -gt 0 ]]; then
tar czf "$BACKUP_FILE" -C "$HOME" "${BACKUP_PATHS[@]}"
log " + User configs backed up."
fi
# Backup system XDG separately (needs sudo)
if [[ -d /etc/xdg ]]; then
SYSTEM_BACKUP="$HOME/moonarch-backup-system-$(date +%Y%m%d-%H%M%S).tar.gz"
sudo tar czf "$SYSTEM_BACKUP" -C / etc/xdg
sudo chown "$USER:$USER" "$SYSTEM_BACKUP"
log " + System configs backed up: $SYSTEM_BACKUP"
fi
log "Backup complete: $(du -h "$BACKUP_FILE" | cut -f1)"
# ============================================================
# Phase 4: Disable Conflicting Display Managers
# ============================================================
if [[ ${#CONFLICTING_DMS[@]} -gt 0 ]]; then
log "Disabling conflicting display managers..."
for dm in "${CONFLICTING_DMS[@]}"; do
sudo systemctl disable "$dm"
log " - $dm disabled"
done
fi
# ============================================================
# Phase 5: Remove Conflicting Packages
# ============================================================
if pacman -Qq pulseaudio &>/dev/null; then
log "Removing PulseAudio (replaced by PipeWire)..."
sudo pacman -Rdd --noconfirm pulseaudio pulseaudio-alsa pulseaudio-bluetooth 2>/dev/null || true
fi
# ============================================================
# Phase 6: Install Packages
# ============================================================
log "Installing official packages..."
if [[ -f "$OFFICIAL_PACKAGES" ]]; then
# shellcheck disable=SC2046
sudo pacman -S --needed --noconfirm $(read_packages "$OFFICIAL_PACKAGES")
else
err "Package list not found: $OFFICIAL_PACKAGES"
exit 1
fi
# Install paru if not present
if ! command -v paru &>/dev/null; then
log "Installing paru..."
PARU_TMPDIR=$(mktemp -d)
git clone https://aur.archlinux.org/paru.git "$PARU_TMPDIR/paru"
(cd "$PARU_TMPDIR/paru" && makepkg -si --noconfirm)
rm -rf "$PARU_TMPDIR"
else
log "paru already installed."
fi
log "Installing AUR packages..."
if [[ -f "$AUR_PACKAGES" ]]; then
# shellcheck disable=SC2046
paru -S --needed --noconfirm $(read_packages "$AUR_PACKAGES")
else
err "AUR package list not found: $AUR_PACKAGES"
exit 1
fi
# Moonarch custom paru repo
log "Setting up Moonarch paru repo..."
PARU_CONF="$HOME/.config/paru/paru.conf"
mkdir -p "$(dirname "$PARU_CONF")"
if ! grep -q '\[moonarch\]' "$PARU_CONF" 2>/dev/null; then
cat >> "$PARU_CONF" <<'EOCONF'
[moonarch]
Url = https://gitea.moonarch.de/nevaforget/moonarch-pkgbuilds.git
EOCONF
log " + Moonarch repo added to paru.conf."
else
log " ~ Moonarch repo already in paru.conf."
fi
paru -Sy --pkgbuilds --noconfirm
paru -S --needed --noconfirm moonset-git moonlock-git moongreet-git
# Themes
log "Installing themes..."
"$SCRIPT_DIR/install-themes.sh"
# ============================================================
# Phase 7: Deploy System Configs (Hard Overwrite)
# ============================================================
log "Deploying XDG defaults to /etc/xdg/..."
sudo cp -r "$DEFAULTS_DIR/xdg/"* /etc/xdg/
sudo find /etc/xdg/rofi -name "*.sh" -exec chmod +x {} \;
# GTK4 theme symlinks
THEME_NAME="Colloid-Catppuccin"
THEME_GTK4="/usr/share/themes/$THEME_NAME/gtk-4.0"
GTK4_XDG="/etc/xdg/gtk-4.0"
if [[ -d "$THEME_GTK4" ]]; then
log "Creating system-wide GTK4 symlinks for $THEME_NAME..."
sudo ln -sf "$THEME_GTK4/gtk-dark.css" "$GTK4_XDG/gtk.css"
sudo ln -sf "$THEME_GTK4/gtk-dark.css" "$GTK4_XDG/gtk-dark.css"
sudo rm -f "$GTK4_XDG/assets"
sudo ln -s "$THEME_GTK4/assets" "$GTK4_XDG/assets"
# libadwaita only reads user CSS from ~/.config/gtk-4.0/
USER_GTK4="$HOME/.config/gtk-4.0"
mkdir -p "$USER_GTK4"
ln -sf "$THEME_GTK4/gtk-dark.css" "$USER_GTK4/gtk.css"
ln -sf "$THEME_GTK4/gtk-dark.css" "$USER_GTK4/gtk-dark.css"
rm -f "$USER_GTK4/assets"
ln -s "$THEME_GTK4/assets" "$USER_GTK4/assets"
else
err "GTK4 theme not found: $THEME_GTK4 — libadwaita apps will use fallback theme."
fi
# gsettings
log "Setting gsettings for GTK theme..."
gsettings set org.gnome.desktop.interface gtk-theme "$THEME_NAME"
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface icon-theme 'Colloid-Grey-Catppuccin-Dark'
gsettings set org.gnome.desktop.interface font-name 'UbuntuSans Nerd Font 11'
# Helper scripts
log "Installing Moonarch helper scripts to /usr/local/bin/..."
sudo install -m 755 "$DEFAULTS_DIR/bin/moonarch-"* /usr/local/bin/
# awww compatibility symlinks
if command -v awww &>/dev/null && ! command -v swww &>/dev/null; then
log "Creating swww -> awww compatibility symlinks..."
sudo ln -s /usr/bin/awww /usr/local/bin/swww
sudo ln -s /usr/bin/awww-daemon /usr/local/bin/swww-daemon
fi
# Zsh configuration
log "Installing Zsh default config..."
sudo cp "$DEFAULTS_DIR/shell/zshrc" /etc/zsh/zshrc.moonarch
if ! grep -q "zshrc.moonarch" /etc/zsh/zshrc 2>/dev/null; then
echo '# Moonarch defaults (overridden by ~/.zshrc)' | sudo tee -a /etc/zsh/zshrc > /dev/null
echo '[[ ! -f "$HOME/.zshrc" ]] && source /etc/zsh/zshrc.moonarch' | sudo tee -a /etc/zsh/zshrc > /dev/null
fi
# For transform: always create a fresh .zshrc that sources Moonarch defaults
log "Creating ~/.zshrc with Moonarch defaults..."
mkdir -p "$HOME/.zshrc.d"
echo "# Load Moonarch defaults, add custom overrides in ~/.zshrc.d/ or below" > "$HOME/.zshrc"
echo "source /etc/zsh/zshrc.moonarch" >> "$HOME/.zshrc"
# greetd / moongreet
log "Configuring greetd + moongreet..."
sudo mkdir -p /etc/greetd
sudo cp "$DEFAULTS_DIR/etc/greetd/config.toml" /etc/greetd/config.toml
sudo mkdir -p /etc/moongreet
sudo cp "$DEFAULTS_DIR/etc/moongreet/moongreet.toml" /etc/moongreet/moongreet.toml
# Niri greeter config (if present)
if [[ -f "$DEFAULTS_DIR/etc/greetd/niri-greeter.kdl" ]]; then
sudo cp "$DEFAULTS_DIR/etc/greetd/niri-greeter.kdl" /etc/greetd/niri-greeter.kdl
fi
# Wallpaper
log "Installing default wallpaper..."
sudo mkdir -p /usr/share/moonarch
sudo cp "$DEFAULTS_DIR/backgrounds/wallpaper.jpg" /usr/share/moonarch/wallpaper.jpg
# ============================================================
# Phase 8: Deploy User Configs (Hard Overwrite)
# ============================================================
# Replace user-level XDG configs for all apps Moonarch manages
log "Deploying XDG configs to ~/.config/ (overwrite)..."
for src_dir in "$DEFAULTS_DIR/xdg/"*/; do
app_name="$(basename "$src_dir")"
# gtk-4.0 is handled separately with Colloid-Catppuccin theme symlinks (Phase 7)
[[ "$app_name" == "gtk-4.0" ]] && continue
dest_dir="$HOME/.config/$app_name"
rm -rf "$dest_dir"
cp -r "$src_dir" "$dest_dir"
log " + $app_name/"
done
# Deploy user defaults (overwrite, no existence check)
log "Deploying user config defaults to ~/.config/ (overwrite)..."
USER_DEFAULTS_DIR="$DEFAULTS_DIR/user"
if [[ -d "$USER_DEFAULTS_DIR" ]]; then
for src_dir in "$USER_DEFAULTS_DIR"/*/; do
app_name="$(basename "$src_dir")"
dest_dir="$HOME/.config/$app_name"
mkdir -p "$dest_dir"
find "$src_dir" -type f -print0 | while IFS= read -r -d '' src_file; do
rel_path="${src_file#"$src_dir"}"
dest_file="$dest_dir/$rel_path"
mkdir -p "$(dirname "$dest_file")"
cp "$src_file" "$dest_file"
log " + $app_name/$rel_path"
done
done
fi
# ============================================================
# Phase 9: Services & Finalization
# ============================================================
log "Enabling services..."
SERVICES=(
"NetworkManager"
"bluetooth"
"docker"
"greetd"
"systemd-timesyncd"
"ufw"
"auto-cpufreq"
)
for service in "${SERVICES[@]}"; do
if systemctl list-unit-files "${service}.service" &>/dev/null; then
sudo systemctl enable "$service"
log " + $service"
else
log " ~ $service not found, skipped."
fi
done
# Set shell to zsh
if [[ "$SHELL" != */zsh ]]; then
log "Setting default shell to zsh..."
chsh -s "$(which zsh)"
fi
# Firewall
log "Configuring UFW..."
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw --force enable
# Docker group
if ! groups | grep -q docker; then
log "Adding user to docker group..."
sudo usermod -aG docker "$USER"
fi
# Directories
mkdir -p "$HOME/Pictures/Screenshots"
mkdir -p "$HOME/Pictures/Wallpaper"
# moonarch-update symlink
log "Creating moonarch-update command..."
sudo ln -sf "$PROJECT_DIR/scripts/update.sh" /usr/local/bin/moonarch-update
# ============================================================
# Phase 10: Done
# ============================================================
echo ""
log "============================================"
log " Moonarch transform complete!"
log "============================================"
echo ""
log "Your previous config is backed up at:"
log " $BACKUP_FILE"
if [[ -n "${SYSTEM_BACKUP:-}" ]]; then
log " $SYSTEM_BACKUP"
fi
echo ""
log "Next steps:"
log " 1. Reboot (greetd replaces your previous display manager)"
log " 2. Place wallpapers in ~/Pictures/Wallpaper/"
log " 3. rustup default stable"
log " 4. User overrides in ~/.config/ or ~/.zshrc.d/"
echo ""
err "Do NOT log out — your previous DM is disabled. Reboot instead."
echo ""

View File

@ -4,37 +4,11 @@
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
OFFICIAL_PACKAGES="$PROJECT_DIR/packages/official.txt"
AUR_PACKAGES="$PROJECT_DIR/packages/aur.txt"
DEFAULTS_DIR="$PROJECT_DIR/defaults"
# --- Helper functions ---
log() {
echo -e "\e[1;34m[Moonarch]\e[0m $*"
}
err() {
echo -e "\e[1;31m[Moonarch ERROR]\e[0m $*" >&2
}
read_packages() {
grep -v '^\s*#' "$1" | grep -v '^\s*$'
}
confirm() {
read -r -p "$1 [y/N] " response
[[ "$response" =~ ^[yY]$ ]]
}
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh"
# --- Prerequisites ---
if [[ $EUID -eq 0 ]]; then
err "Do NOT run as root."
exit 1
fi
check_not_root
# --- 1. Update Moonarch repo ---