165 lines
9.1 KiB
Shell
165 lines
9.1 KiB
Shell
#!/usr/bin/env bash
|
|
# What was ticked beyond the shell itself: the terminal setup, and each thing a bare niri lacks.
|
|
# A file already there is kept as <name>.bak-caelestia. Anything needing sudo says so first.
|
|
|
|
set -euo pipefail
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/log.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/privileges.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/packages.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib/apps.sh"
|
|
|
|
BIN="${CAELESTIA_BIN:-$HOME/.local/bin}"
|
|
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
ticked() { [[ " ${OPTIONS:-} " == *" $1 "* ]]; }
|
|
|
|
# Puts a stock file in place, keeping what was there.
|
|
place() {
|
|
local from="$1" to="$2"
|
|
mkdir -p "$(dirname "$to")"
|
|
if [[ -e "$to" ]] && ! cmp -s "$from" "$to"; then
|
|
[[ -e "$to.bak-caelestia" ]] || cp -a "$to" "$to.bak-caelestia"
|
|
fi
|
|
cp "$from" "$to"
|
|
}
|
|
echo
|
|
if ticked terminal; then
|
|
place "$BUNDLE_DIR/assets/dots/kitty/kitty.conf" "$CONFIG/kitty/kitty.conf"
|
|
place "$BUNDLE_DIR/assets/dots/fish/config.fish" "$CONFIG/fish/config.fish"
|
|
place "$BUNDLE_DIR/assets/dots/fish/functions/fish_greeting.fish" "$CONFIG/fish/functions/fish_greeting.fish"
|
|
for f in config.jsonc fetch.py arch-logo.ans; do place "$BUNDLE_DIR/assets/dots/fastfetch/$f" "$CONFIG/fastfetch/$f"; done
|
|
# The prompt is written from the scheme, so keep any starship.toml first, unless it is ours
|
|
# (assets/templates/starship-colors.toml) from an earlier run.
|
|
if [[ -e "$CONFIG/starship.toml" && ! -e "$CONFIG/starship.toml.bak-caelestia" ]] &&
|
|
! head -1 "$CONFIG/starship.toml" | grep -q '^# Two lines: status and folder'; then cp -a "$CONFIG/starship.toml" "$CONFIG/starship.toml.bak-caelestia"; fi
|
|
if [[ -x "$BIN/caelestia" ]]; then
|
|
"$BIN/caelestia" themes enable enableKitty >/dev/null
|
|
"$BIN/caelestia" themes enable enableStarship >/dev/null
|
|
fi
|
|
ok "Terminal setup written. Make fish your shell with: chsh -s /usr/bin/fish"
|
|
fi
|
|
# Colours exist once there is a wallpaper, and the login screen's sync below needs them. The
|
|
# shell would only do this at its first start, which is too late for that.
|
|
if [[ -x "$BIN/caelestia" && ! -e "${XDG_STATE_HOME:-$HOME/.local/state}/niri-caelestia/wallpaper/path.txt" && ! -e "${XDG_STATE_HOME:-$HOME/.local/state}/caelestia/wallpaper/path.txt" ]]; then
|
|
"$BIN/caelestia" wallpaper -f "${XDG_DATA_HOME:-$HOME/.local/share}/caelestia-niri/images/wallpaper.webp" >/dev/null 2>&1 || true
|
|
fi
|
|
for own in ${OWN_ON:-}; do
|
|
ui_run "Installing ${own#@}" install_own "$own" || warn "Could not install ${own#@}"
|
|
done
|
|
# What the keybinds open and the dock shows: the first of each kind that is here. A choice
|
|
# already made stays.
|
|
if [[ -x "$BIN/caelestia" ]]; then
|
|
for kind in terminal:terminal files:explorer editor:editor browser:browser; do
|
|
while IFS='|' read -r pkg name cmds dock; do
|
|
app_present "$cmds" || continue
|
|
"$BIN/caelestia" apps default "${kind#*:}" "${cmds%% *}"
|
|
if [[ "$kind" == files:* || "$kind" == browser:* ]]; then "$BIN/caelestia" apps pin "$dock"; fi
|
|
break
|
|
done < <(app_list "${kind%%:*}")
|
|
done
|
|
fi
|
|
if ticked cursor; then
|
|
icons="${XDG_DATA_HOME:-$HOME/.local/share}/icons"
|
|
mkdir -p "$icons" "$HOME/.icons/default" "$CONFIG/niri"
|
|
cp -a "$BUNDLE_DIR/assets/cursors/material_light_cursors" "$icons/"
|
|
printf '[Icon Theme]\nInherits=material_light_cursors\n' >"$HOME/.icons/default/index.theme"
|
|
if [[ ! -e "$CONFIG/niri/caelestia-cursor.kdl" ]]; then
|
|
printf 'cursor {\n xcursor-theme "material_light_cursors"\n xcursor-size 36\n}\n' >"$CONFIG/niri/caelestia-cursor.kdl"
|
|
fi
|
|
if command -v gsettings >/dev/null 2>&1; then
|
|
gsettings set org.gnome.desktop.interface cursor-theme material_light_cursors 2>/dev/null || true
|
|
fi
|
|
ok "Material cursor set"
|
|
fi
|
|
if ticked login; then
|
|
if [[ -d /usr/share/sddm/themes/caelestia ]]; then
|
|
info "Setting the login screen, with sudo"
|
|
# Last by name, so it beats any other file there. The theme's own caelestia.conf sorts first.
|
|
printf '[Theme]\nCurrent=caelestia\nCursorTheme=material_light_cursors\nCursorSize=36\n' | caelestia_sudo tee /etc/sddm.conf.d/zz-caelestia.conf >/dev/null || warn "The login screen was left alone"
|
|
# The greeter is another user: it cannot see a cursor in this home.
|
|
caelestia_sudo cp -a "$BUNDLE_DIR/assets/cursors/material_light_cursors" /usr/share/icons/ || true
|
|
if ! systemctl is-enabled --quiet display-manager.service 2>/dev/null; then
|
|
caelestia_sudo systemctl enable sddm.service || true
|
|
fi
|
|
# The theme's template, then its first sync. It reads what `caelestia` renders from it.
|
|
mkdir -p "$CONFIG/niri/caelestia/templates"
|
|
if [[ ! -e "$CONFIG/niri/caelestia/templates/sddm-theme.conf" ]]; then
|
|
cp /usr/share/sddm/themes/caelestia/theme.conf.template "$CONFIG/niri/caelestia/templates/sddm-theme.conf" || true
|
|
fi
|
|
"$BIN/caelestia" scheme reapply >/dev/null 2>&1 || true
|
|
caelestia_sudo /usr/share/sddm/themes/caelestia/scripts/sync.sh >/dev/null 2>&1 || warn "The login screen's first sync failed"
|
|
if ticked loginsync; then
|
|
rule="$(mktemp)"
|
|
printf '%s ALL=(root) NOPASSWD: /usr/share/sddm/themes/caelestia/scripts/sync.sh\n' "$USER" >"$rule"
|
|
# Debian keeps visudo in /usr/sbin, outside a user's PATH. No check, no rule.
|
|
if "$(command -v visudo || echo /usr/sbin/visudo)" -cf "$rule" >/dev/null 2>&1; then
|
|
caelestia_sudo install -o root -g root -m 0440 "$rule" /etc/sudoers.d/caelestia-sddm-sync || true
|
|
"$BIN/caelestia" hooks login
|
|
else
|
|
warn "visudo could not check the sync rule, so the login screen is synced only now"
|
|
fi
|
|
rm -f "$rule"
|
|
fi
|
|
ok "Login screen set"
|
|
else
|
|
warn "The Caelestia SDDM theme did not install, so the login screen is unchanged"
|
|
fi
|
|
fi
|
|
if ticked monitors && [[ ! -e /etc/modules-load.d/i2c-dev.conf ]]; then
|
|
info "Loading i2c-dev at boot, with sudo: ddcutil reaches monitors through it"
|
|
printf 'i2c-dev\n' | caelestia_sudo tee /etc/modules-load.d/i2c-dev.conf >/dev/null || warn "i2c-dev was not set to load"
|
|
fi
|
|
if ticked portals; then
|
|
mkdir -p "$CONFIG/xdg-desktop-portal"
|
|
printf '[preferred]\ndefault=gnome;gtk;\norg.freedesktop.impl.portal.FileChooser=gtk;\n' >"$CONFIG/xdg-desktop-portal/niri-portals.conf"
|
|
ok "Portals set up"
|
|
fi
|
|
if ticked keyring; then
|
|
if [[ -f /etc/pam.d/sddm ]] && ! grep -q pam_gnome_keyring /etc/pam.d/sddm; then
|
|
info "Adding gnome-keyring to SDDM's PAM file, with sudo"
|
|
printf 'auth optional pam_gnome_keyring.so\nsession optional pam_gnome_keyring.so auto_start\n' | caelestia_sudo tee -a /etc/pam.d/sddm >/dev/null || warn "SDDM's PAM file was left alone"
|
|
fi
|
|
ok "Keyring set up"
|
|
fi
|
|
if ticked qt; then
|
|
mkdir -p "$CONFIG/environment.d"
|
|
printf 'QT_QPA_PLATFORMTHEME=qt6ct\n' >"$CONFIG/environment.d/90-caelestia-qt.conf"
|
|
ok "Qt theming set up, from your next login"
|
|
fi
|
|
if ticked automount; then
|
|
mkdir -p "$CONFIG/autostart"
|
|
printf '[Desktop Entry]\nType=Application\nName=udiskie\nExec=udiskie --no-tray\n' >"$CONFIG/autostart/udiskie.desktop"
|
|
ok "Automount set up"
|
|
fi
|
|
if ticked tray; then
|
|
if ! command -v xembedsniproxy >/dev/null 2>&1; then
|
|
warn "xembedsniproxy is not installed: it is the AUR's xembed-sni-proxy-standalone-git, or plasma-workspace"
|
|
elif grep -rqs xembedsniproxy "$CONFIG/niri" "$CONFIG/autostart"; then
|
|
ok "X11 tray icons: xembedsniproxy is already started by your config"
|
|
else
|
|
# The shell runs ~/.config/autostart at login.
|
|
mkdir -p "$CONFIG/autostart"
|
|
printf '[Desktop Entry]\nType=Application\nName=xembedsniproxy\nExec=xembedsniproxy\n' >"$CONFIG/autostart/xembedsniproxy.desktop"
|
|
ok "X11 tray icons set up, from your next login"
|
|
fi
|
|
fi
|
|
# The shell starts wlsunset, cliphist's watchers and wl-clip-persist itself, so these only check.
|
|
if ticked nightlight; then
|
|
if command -v wlsunset >/dev/null 2>&1; then ok "Night light ready"; else warn "wlsunset is not installed, so Night Light cannot turn on"; fi
|
|
fi
|
|
if ticked clipboard; then
|
|
if command -v cliphist >/dev/null 2>&1; then ok "Clipboard history ready"; else warn "cliphist is not installed, so Mod+V shows an empty history"; fi
|
|
fi
|
|
if ticked video; then
|
|
if command -v mpvpaper >/dev/null 2>&1; then ok "Video wallpapers ready"
|
|
else warn "mpvpaper is not installed (AUR on Arch, built from source elsewhere): a video wallpaper shows a still frame"; fi
|
|
fi
|
|
if ticked lock; then
|
|
if [[ ! -f /etc/pam.d/caelestia-lock ]]; then
|
|
info "Installing the lock's PAM file, with sudo"
|
|
printf 'auth include login\n' | caelestia_sudo tee /etc/pam.d/caelestia-lock >/dev/null || warn "No PAM file: the lock falls back to swaylock's"
|
|
fi
|
|
if [[ ! -e "${XDG_STATE_HOME:-$HOME/.local/state}/niri-caelestia/lock-proved" && ! -e "${XDG_STATE_HOME:-$HOME/.local/state}/caelestia/lock-proved" ]]; then
|
|
info "Until a preview passes the lock is swaylock. The installer offers one at the end."
|
|
fi
|
|
fi
|
|
caelestia_stop_sudo_keepalive
|