#!/usr/bin/env bash # install.en.sh – interactive installer for the labwc desktop. # # This script does not accept installation parameters. It guides you # through a menu and asks about all optional components: # # • full installation # • change theme only (light/dark) # • patch GParted for Wayland only # • set up keyring (gnome-keyring) only # # Optional components: Node.js (nvm), opencode, uv, Cargo/Rust (rustup), # Ollama, Docker (incl. compose), Rusticl for AMD, fish as the default # login shell and pixman as the renderer in a virtual machine. # # The bundle uses @HOME@ and @NODE_BIN@ as placeholders. They are # replaced at install time with the real home directory and the nvm bin # path. This way the package contains no fixed user name. set -Eeuo pipefail SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) MODE="" DO_NODE=0 DO_OPENCODE=0 DO_UV=0 DO_CARGO=0 DO_OLLAMA=0 DO_DOCKER=0 DO_RUSTICL=0 DO_VM_RENDERER=0 SET_FISH_SHELL=0 BACKUP_DIR="" NVM_VERSION=${NVM_VERSION:-v0.41.0} if [ -t 1 ]; then B=$'\033[1;34m'; G=$'\033[1;32m'; Y=$'\033[1;33m'; R=$'\033[1;31m'; N=$'\033[0m' else B=""; G=""; Y=""; R=""; N="" fi info() { printf '%s==>%s %s\n' "$B" "$N" "$*"; } ok() { printf '%s ✓%s %s\n' "$G" "$N" "$*"; } warn() { printf '%sWarning:%s %s\n' "$Y" "$N" "$*" >&2; } err() { printf '%sError:%s %s\n' "$R" "$N" "$*" >&2; } die() { err "$*"; exit 1; } # Identity of the user who started this script. $USER and $HOME are # environment variables and can be stale (exported from another account, # `su` without `-`, etc.). Everything user-bound – home directory, shell, # docker group, dotfiles – is derived from the passwd database instead, # so the installer always configures the user who actually ran it. USER_NAME=$(id -un) USER_HOME=$(getent passwd "$USER_NAME" 2>/dev/null | cut -d: -f6 || true) if [ -z "$USER_HOME" ]; then USER_HOME=${HOME:?} elif [ -n "${HOME:-}" ] && [ "$HOME" != "$USER_HOME" ]; then warn "HOME is '$HOME', but '$USER_NAME' is registered with '$USER_HOME' – using '$USER_HOME'." fi usage() { cat <<'EOF' Usage: ./install.en.sh This script is interactive and does not accept installation parameters. Start it without arguments and follow the menu. EOF } # ---------------------------------------------------------------- Prompts ask_yes_no() { local prompt=$1 default=${2:-n} answer if [ ! -t 0 ]; then case "$default" in y|Y) return 0 ;; *) return 1 ;; esac fi case "$default" in y|Y) prompt="$prompt [Y/n]" ;; *) prompt="$prompt [y/N]" ;; esac while true; do read -r -p "$prompt " answer || answer="" answer=${answer:-$default} case "$answer" in y|Y|yes|Yes) return 0 ;; n|N|no|No) return 1 ;; *) printf 'Please enter y or n.\n' >&2 ;; esac done } ask_theme() { local answer if [ ! -t 0 ]; then printf 'dark\n' return 0 fi # Menu goes to stderr: the return value is captured via $(ask_theme). printf '\nWhich theme?\n' >&2 printf ' 1) dark (Breeze Dark)\n' >&2 printf ' 2) light (Breeze Light)\n' >&2 while true; do read -r -p "Choice [1/2, default: 1]: " answer || answer="" case "${answer:-1}" in 1|d|D|dark|Dark) printf 'dark\n'; return 0 ;; 2|l|L|light|Light) printf 'light\n'; return 0 ;; *) printf 'Please enter 1 or 2.\n' >&2 ;; esac done } has_amd_gpu() { local f for f in /sys/class/drm/card*/device/vendor; do [ -f "$f" ] || continue if [ "$(cat "$f" 2>/dev/null)" = "0x1002" ]; then return 0 fi done return 1 } in_virtual_machine() { if command -v systemd-detect-virt >/dev/null 2>&1; then systemd-detect-virt --vm --quiet && return 0 return 1 fi # Fallback without systemd-detect-virt: DMI data of known hypervisors local f value for f in /sys/class/dmi/id/product_name \ /sys/class/dmi/id/sys_vendor \ /sys/class/dmi/id/bios_vendor; do [ -r "$f" ] || continue value=$(cat "$f" 2>/dev/null || true) case "$value" in *QEMU*|*KVM*|*VirtualBox*|*VMware*|*Hyper-V*|*Xen*|*Bochs*|*Parallels*) return 0 ;; esac done return 1 } require_sudo() { command -v sudo >/dev/null 2>&1 \ || die "sudo is missing. Please install as root or install sudo first." info "sudo privileges are required (apt/greetd/services/GParted/keyring) …" sudo -v || die "sudo failed." } # ---------------------------------------------------------------- Packages APT_PACKAGES=( labwc waybar kitty foot fuzzel thunar thunar-volman tumbler udisks2 gvfs gparted loupe swaybg mako-notifier swayidle swaylock greetd tuigreet pipewire pipewire-pulse pipewire-audio pipewire-alsa wireplumber alsa-utils network-manager wpasupplicant wireless-regdb grim slurp wl-clipboard swappy libnotify-bin wdisplays wlr-randr wlopm flatpak xdg-desktop-portal xdg-desktop-portal-gtk gnome-keyring polkitd libpam-gnome-keyring libsecret-tools xdg-utils xdg-user-dirs dbus dbus-user-session arc-theme fonts-dejavu-core fonts-dejavu-mono fonts-jetbrains-mono fish kf6-breeze-icon-theme librsvg2-common gtk-update-icon-cache libglib2.0-bin gsettings-desktop-schemas dconf-gsettings-backend dconf-service dconf-cli fontconfig python3 python3-venv nano less fastfetch btop htop nvtop mousepad hx kew python3-gi gir1.2-gtk-3.0 mesa-opencl-icd ocl-icd-libopencl1 clinfo pciutils mesa-va-drivers mesa-vdpau-drivers mesa-vulkan-drivers qtwayland5 git curl wget xz-utils unzip ca-certificates zstd jq lazygit ) install_packages() { command -v apt-get >/dev/null 2>&1 \ || die "This script only supports Debian/Ubuntu (apt)." # shellcheck disable=SC1091 . /etc/os-release 2>/dev/null || true if [ "${ID:-}" != "debian" ]; then warn "Tested on Debian 13 (trixie); detected: ${PRETTY_NAME:-unknown}." fi # Cargo/Rust needs a C toolchain and linker. `gcc` only Recommends # libc6-dev, which --no-install-recommends would skip – build-essential # pulls in cc, libc6-dev, make and g++ as real dependencies. if [ "$DO_CARGO" -eq 1 ] \ || [ -x "${CARGO_HOME:-$USER_HOME/.cargo}/bin/cargo" ] \ || command -v cargo >/dev/null 2>&1; then APT_PACKAGES+=(build-essential) fi # docker.io only Recommends docker-cli; with --no-install-recommends # the `docker` command itself would be missing. docker-compose ships # both `docker compose` (CLI plugin) and the `docker-compose` wrapper. if [ "$DO_DOCKER" -eq 1 ]; then APT_PACKAGES+=(docker.io docker-cli docker-compose) fi info "Updating apt package lists …" sudo apt-get update local p available=() missing=() for p in "${APT_PACKAGES[@]}"; do if apt-cache show "$p" >/dev/null 2>&1; then available+=("$p") else missing+=("$p") fi done if [ ${#missing[@]} -gt 0 ]; then warn "Not available and will be skipped: ${missing[*]}" fi [ ${#available[@]} -gt 0 ] || die "None of the required packages is available." info "Installing ${#available[@]} packages …" sudo env DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends "${available[@]}" ok "Packages installed." } # ---------------------------------------------------------------- PolicyKit agent install_polkit_agent() { if [ -x /usr/libexec/xfce-polkit ] || command -v xfce-polkit >/dev/null 2>&1; then ok "xfce-polkit (PolicyKit agent) already installed" return 0 fi # Starting with Debian 14 (forky), xfce-polkit is in the official repositories. if apt-cache show xfce-polkit >/dev/null 2>&1; then info "Installing xfce-polkit …" if sudo env DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends xfce-polkit; then ok "xfce-polkit installed." return 0 fi warn "apt installation of xfce-polkit failed – trying package download." fi # Debian 13 (trixie): the package arrived only after the freeze and is # only in unstable. All dependencies are present in trixie in matching # versions, so the .deb can be installed directly. local arch deb tmp arch=$(dpkg --print-architecture 2>/dev/null) || arch=amd64 tmp=$(mktemp -d) info "xfce-polkit is missing in trixie – downloading the package from Debian unstable …" deb=$(curl -fsSL https://deb.debian.org/debian/pool/main/x/xfce-polkit/ 2>/dev/null \ | grep -oE "xfce-polkit_[^\"]*_${arch}\.deb" | sort -Vu | tail -n 1) if [ -z "$deb" ] \ || ! curl -fsSL -o "$tmp/$deb" "https://deb.debian.org/debian/pool/main/x/xfce-polkit/$deb"; then rm -rf "$tmp" warn "xfce-polkit could not be downloaded – pkexec/gparted cannot ask for the password." return 0 fi if sudo dpkg -i "$tmp/$deb" >/dev/null 2>&1 \ || sudo env DEBIAN_FRONTEND=noninteractive apt-get install -f -y >/dev/null 2>&1; then ok "xfce-polkit installed ($deb)." else warn "Installation of $deb failed." fi rm -rf "$tmp" } # ---------------------------------------------------------------- GParted patch_gparted_wayland() { local target=/usr/sbin/gparted tmp block if [ ! -f "$target" ]; then warn "gparted is not installed – skipping the Wayland patch." return 0 fi if grep -q 'desktop-setup: wayland root' "$target" 2>/dev/null; then ok "gparted Wayland patch already present" return 0 fi info "Patching gparted for root startup under Wayland …" tmp=$(mktemp) block=$(mktemp) cat >"$block" <<'EOF' # # desktop-setup: wayland root # Run GParted on the Wayland display of the desktop user when started # as root (pkexec/sudo). labwc's Xwayland denies root access and X11 # cookies are not available to root, so use the Wayland backend. # if test "x`id -u`" = "x0" && test "x${WAYLAND_DISPLAY:-}" = "x"; then _uid="${PKEXEC_UID:-${SUDO_UID:-}}" if test -n "$_uid"; then _runtime="/run/user/$_uid" for _sock in "$_runtime"/wayland-*; do case "$_sock" in *.lock) continue ;; esac if test -S "$_sock"; then XDG_RUNTIME_DIR="$_runtime" WAYLAND_DISPLAY="${_sock##*/}" GDK_BACKEND=wayland export XDG_RUNTIME_DIR WAYLAND_DISPLAY GDK_BACKEND break fi done fi fi EOF awk -v blockfile="$block" ' { print } /exit \$status$/ { seen = 1; next } seen && /^fi$/ { print "" while ((getline line < blockfile) > 0) print line close(blockfile) seen = 0 } ' "$target" >"$tmp" if ! grep -q 'desktop-setup: wayland root' "$tmp" 2>/dev/null; then rm -f "$tmp" "$block" warn "gparted patch not possible (unexpected file version)." return 0 fi sudo install -m 755 "$tmp" "$target" rm -f "$tmp" "$block" ok "gparted patched (root startup uses the Wayland display)." } install_gparted() { if command -v gparted >/dev/null 2>&1; then ok "gparted is already installed." return 0 fi info "Installing gparted …" sudo apt-get update sudo env DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends gparted \ || { warn "gparted could not be installed."; return 0; } ok "gparted installed." } # ---------------------------------------------------------------- Icons # Checks whether both Qogir variants are complete. Qogir-Manjaro-Dark # symlinks 48/96/128/scalable/symbolic relatively into Qogir-Manjaro. If # the light variant is missing, Thunar finds no icons despite an existing # index.theme. qogir_icons_complete() { local dest="$USER_HOME/.local/share/icons" local d p for d in Qogir-Manjaro Qogir-Manjaro-Dark; do for p in index.theme 16/places/folder.svg 48/places/folder.svg \ scalable/places/folder.svg \ scalable/apps/org.xfce.thunar.svg \ cursors/default; do # -s also catches empty/corrupted files from a broken copy. [ -s "$dest/$d/$p" ] || return 1 done done return 0 } install_icons() { local dest="$USER_HOME/.local/share/icons" local ver=2025-02-15 local sha=b0d07cad5601e0341a53a62df0ed111823b75fc38741d435486620a59fb239ee local cand tarball="" tmp qogir_dir local bundle_sha=6a2863348a6935686be2403b9a168e431b94f1108419bcff3e31edd6a3aec0b1 mkdir -p "$dest" for cand in "$SCRIPT_DIR/assets/Qogir-icons-$ver-all.tar.gz" \ "$USER_HOME"/Backups/*/icons/Qogir-icons-$ver-all.tar.gz; do if [ -f "$cand" ]; then tarball=$cand; break; fi done if [ -n "$tarball" ]; then # The bundled archive is the icon tree of the reference system # where the icons work. Always extract it, so that a stale, # partial or wrongly linked tree can never survive. if [ "$tarball" = "$SCRIPT_DIR/assets/Qogir-icons-$ver-all.tar.gz" ] \ && ! printf '%s %s\n' "$bundle_sha" "$tarball" \ | sha256sum -c - >/dev/null 2>&1; then die "The bundled Qogir archive is corrupted (checksum mismatch). Copy desktop-setup again." fi info "Installing Qogir icons from the bundled archive: $tarball" rm -rf "$dest/Qogir-Manjaro" "$dest/Qogir-Manjaro-Dark" if ! tar -xzf "$tarball" -C "$dest" Qogir-Manjaro Qogir-Manjaro-Dark; then die "The bundled Qogir archive could not be extracted." fi elif qogir_icons_complete; then ok "Qogir icons are already fully installed." else # Remove incomplete or stale leftovers so that no mixed symlinks # remain. rm -rf "$dest/Qogir-Manjaro" "$dest/Qogir-Manjaro-Dark" info "Downloading Qogir icons $ver from GitHub …" tmp=$(mktemp -d) if ! curl -fL --retry 3 -o "$tmp/qogir.tar.gz" \ "https://github.com/vinceliuice/Qogir-icon-theme/archive/refs/tags/$ver.tar.gz"; then rm -rf "$tmp" die "Qogir download failed and no bundled archive is available." fi if ! printf '%s %s\n' "$sha" "$tmp/qogir.tar.gz" | sha256sum -c - >/dev/null 2>&1; then rm -rf "$tmp" die "Checksum of the Qogir source does not match." fi if ! tar -xzf "$tmp/qogir.tar.gz" -C "$tmp"; then rm -rf "$tmp" die "Qogir archive could not be extracted." fi # Only the two required variants (light/dark) instead of all 9. # Note: in the Qogir script (tag 2025-02-15) the colour table is # swapped – "-c dark" produces "-Light" there. Patch the order; # if the pattern no longer matches, build all Manjaro variants # and remove the unwanted light one afterwards. qogir_dir="$tmp/Qogir-icon-theme-$ver" if grep -qx "COLOR_VARIANTS=('' '-Light' '-Dark')" "$qogir_dir/install.sh"; then sed -i "s/^COLOR_VARIANTS=('' '-Light' '-Dark')\$/COLOR_VARIANTS=('' '-Dark' '-Light')/" \ "$qogir_dir/install.sh" if ! ( cd "$qogir_dir" && ./install.sh -d "$dest" -t manjaro -c standard dark ); then rm -rf "$tmp" die "Qogir installation script failed." fi else if ! ( cd "$qogir_dir" && ./install.sh -d "$dest" -t manjaro -c all ); then rm -rf "$tmp" die "Qogir installation script failed." fi rm -rf "$dest/Qogir-Manjaro-Light" fi rm -rf "$tmp" fi # Always rebuild the cache – a missing or stale icon-theme.cache is one # of the causes of wrong Thunar icons. local d for d in Qogir-Manjaro Qogir-Manjaro-Dark; do if [ -e "$dest/$d/index.theme" ]; then gtk-update-icon-cache -f "$dest/$d" >/dev/null 2>&1 || true fi done if qogir_icons_complete; then ok "Qogir icons installed." else die "Qogir icons are incomplete after installation – Thunar would show Adwaita icons." fi } # libXcursor (labwc/mouse pointer, GTK under X11) only searches # ~/.icons, /usr/share/icons and /usr/share/pixmaps – not # ~/.local/share/icons. Therefore point ~/.icons at the icon directory # (as on the reference system). ensure_cursor_theme_link() { local dest="$USER_HOME/.local/share/icons" local icons_link="$USER_HOME/.icons" local d names [ -d "$dest" ] || return 0 # Already ~/.icons -> ~/.local/share/icons? Then everything is done. if [ -L "$icons_link" ]; then if [ "$(readlink -f "$icons_link")" = "$(readlink -f "$dest")" ]; then return 0 fi warn "~/.icons already points to $(readlink "$icons_link") – Qogir cursors will not be linked." return 0 fi if [ ! -e "$icons_link" ]; then if ln -s "$dest" "$icons_link"; then ok "~/.icons -> ~/.local/share/icons linked." else warn "Could not create ~/.icons as a symlink." fi return 0 fi # Legacy install: a real directory containing only our two Qogir # links. Replace it with the whole-directory symlink so that the # relative links of Qogir-Manjaro-Dark resolve as well. if [ -d "$icons_link" ]; then names=$(ls -A "$icons_link" 2>/dev/null | sort | tr '\n' ' ') if [ "$names" = "Qogir-Manjaro Qogir-Manjaro-Dark " ] \ && [ -L "$icons_link/Qogir-Manjaro" ] \ && [ -L "$icons_link/Qogir-Manjaro-Dark" ]; then rm -rf "$icons_link" if ln -s "$dest" "$icons_link"; then ok "~/.icons switched to ~/.local/share/icons." return 0 fi fi fi # Real directory with its own content: leave it alone, only add the # two Qogir variants as links. mkdir -p "$icons_link" for d in Qogir-Manjaro Qogir-Manjaro-Dark; do [ -d "$dest/$d" ] || continue ln -sfn "$dest/$d" "$icons_link/$d" done } # ---------------------------------------------------------------- Fonts install_fonts() { local dest="$USER_HOME/.local/share/fonts/NerdFonts" local confdir="$USER_HOME/.config/fontconfig/conf.d" local tmp found mkdir -p "$dest" "$confdir" if [ -f "$dest/SymbolsNerdFont-Regular.ttf" ] \ && [ -f "$dest/SymbolsNerdFontMono-Regular.ttf" ]; then ok "Symbols Nerd Font is already installed – skipping." fc-cache -f >/dev/null 2>&1 || true return 0 fi info "Downloading Symbols Nerd Font …" tmp=$(mktemp -d) if curl -fL --retry 3 -o "$tmp/nerd.tar.xz" \ "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/NerdFontsSymbolsOnly.tar.xz"; then tar -xf "$tmp/nerd.tar.xz" -C "$tmp" cp -f "$tmp/SymbolsNerdFont-Regular.ttf" \ "$tmp/SymbolsNerdFontMono-Regular.ttf" "$dest/" [ -f "$tmp/10-nerd-font-symbols.conf" ] && \ cp -f "$tmp/10-nerd-font-symbols.conf" "$confdir/" ok "Nerd Fonts installed." else warn "Download failed – trying an existing backup …" found=0 local cand for cand in "$USER_HOME"/Backups/*/dotfiles-*.tar.gz; do [ -f "$cand" ] || continue rm -rf "$tmp/backup"; mkdir -p "$tmp/backup" if tar -xzf "$cand" -C "$tmp/backup" \ .local/share/fonts/NerdFonts \ .config/fontconfig/conf.d/10-nerd-font-symbols.conf 2>/dev/null; then cp -f "$tmp/backup/.local/share/fonts/NerdFonts/"*.ttf "$dest/" 2>/dev/null || continue cp -f "$tmp/backup/.config/fontconfig/conf.d/10-nerd-font-symbols.conf" \ "$confdir/" 2>/dev/null || true found=1; break fi done if [ "$found" -eq 1 ]; then ok "Nerd Fonts restored from backup." else warn "Nerd Fonts are still missing; Waybar symbols may appear as boxes." fi fi rm -rf "$tmp" fc-cache -f >/dev/null 2>&1 || true } # ---------------------------------------------------------------- Dotfiles backup_existing() { local src=$1 rel target while IFS= read -r -d '' target; do rel=${target#"$src"/} target="$USER_HOME/$rel" [ -e "$target" ] || [ -L "$target" ] || continue mkdir -p "$BACKUP_DIR/$(dirname -- "$rel")" cp -a -- "$target" "$BACKUP_DIR/$rel" 2>/dev/null || true done < <(find "$src" -type f -print0) } escape_sed_replacement() { printf '%s' "$1" | sed -e 's/[\\&|]/\\&/g' } # Returns the nvm bin path including a trailing colon, or "". detect_node_prefix() { local node_bin node_dir node_bin=$(command -v node 2>/dev/null || true) if [ -z "$node_bin" ] && [ -d "$USER_HOME/.nvm/versions/node" ]; then node_bin=$(find "$USER_HOME/.nvm/versions/node" -maxdepth 3 \ -type f -name node -perm -u+x 2>/dev/null \ | sort -V | tail -n 1 || true) fi [ -n "$node_bin" ] || return 0 node_dir=$(dirname -- "$node_bin") case "$node_dir" in "$USER_HOME"/.nvm/versions/node/*/bin) printf '%s:' "$node_dir" ;; esac return 0 } substitute_placeholders() { local node_prefix=$1 f home_esc node_esc home_esc=$(escape_sed_replacement "$USER_HOME") node_esc=$(escape_sed_replacement "$node_prefix") while IFS= read -r -d '' f; do grep -Iq . "$f" 2>/dev/null || continue if grep -q '@HOME@\|@NODE_BIN@' "$f" 2>/dev/null; then sed -i -e "s|@HOME@|$home_esc|g" \ -e "s|@NODE_BIN@|$node_esc|g" "$f" fi done < <(find "$USER_HOME/.config" "$USER_HOME/.local/bin" -type f -print0 2>/dev/null) } apply_dotfiles() { local stamp node_prefix node_prefix=$(detect_node_prefix) stamp=$(date +%Y%m%d-%H%M%S) BACKUP_DIR="$USER_HOME/Backups/desktop-setup-$stamp" mkdir -p "$BACKUP_DIR" info "Backing up existing files to $BACKUP_DIR …" backup_existing "$SCRIPT_DIR/home" backup_existing "$SCRIPT_DIR/themes/$MODE/home" info "Copying dotfiles …" cp -a "$SCRIPT_DIR/home/." "$USER_HOME/" cp -a "$SCRIPT_DIR/themes/$MODE/home/." "$USER_HOME/" install -Dm644 "$SCRIPT_DIR/assets/labwc-dark.png" \ "$USER_HOME/.local/share/backgrounds/labwc-dark.png" install -Dm644 "$SCRIPT_DIR/assets/labwc-light.png" \ "$USER_HOME/.local/share/backgrounds/labwc-light.png" chmod 755 "$USER_HOME/.local/bin/screenshot" \ "$USER_HOME/.local/bin/session-menu" \ "$USER_HOME/.local/bin/greeter-theme" \ "$USER_HOME/.local/bin/set-gtk-settings" \ "$USER_HOME/.local/bin/update-gtk4-dark-css" \ "$USER_HOME/.local/bin/idle-action" 2>/dev/null || true substitute_placeholders "$node_prefix" # Avoid an empty backup directory if [ -z "$(find "$BACKUP_DIR" -type f -print -quit)" ]; then rmdir "$BACKUP_DIR" 2>/dev/null || true BACKUP_DIR="" fi ok "Dotfiles copied." } # ---------------------------------------------------------------- Rusticl setup_rusticl() { [ "$DO_RUSTICL" -eq 1 ] || return 0 local vendors="$USER_HOME/.config/OpenCL/vendors" local env_file="$USER_HOME/.config/labwc/environment" local envd_file="$USER_HOME/.config/environment.d/90-labwc.conf" local fish_file="$USER_HOME/.config/fish/config.fish" info "Setting up Rusticl (OpenCL via Mesa/radeonsi) …" mkdir -p "$vendors" printf 'libRusticlOpenCL.so.1\n' > "$vendors/rusticl.icd" if [ -f "$env_file" ] && ! grep -q 'RUSTICL_ENABLE' "$env_file"; then cat >> "$env_file" <> "$envd_file" <> "$fish_file" <<'EOF' # ---------- Rusticl (OpenCL) ---------- set -gx RUSTICL_ENABLE radeonsi set -gx OCL_ICD_VENDORS "$HOME/.config/OpenCL/vendors" EOF fi ok "Rusticl configured (active after the next login)." } # ---------------------------------------------------------------- VM renderer setup_vm_renderer() { [ "$DO_VM_RENDERER" -eq 1 ] || return 0 local env_file="$USER_HOME/.config/labwc/environment" info "Setting pixman as the software renderer for the VM …" mkdir -p "$(dirname -- "$env_file")" touch "$env_file" if grep -qE '^[[:space:]]*WLR_RENDERER=' "$env_file"; then # Replace an existing line so that no duplicate values are created. sed -i 's|^[[:space:]]*WLR_RENDERER=.*|WLR_RENDERER=pixman|' "$env_file" else cat >> "$env_file" <<'EOF' # Virtual machine: software renderer (pixman) instead of GPU/GL. # Prevents graphics glitches and black windows when the VM does not # provide working 3D acceleration. WLR_RENDERER=pixman EOF fi ok "pixman renderer set (active after the next login)." } # ---------------------------------------------------------------- GTK install_gtk4_dark_css() { local script="$USER_HOME/.local/bin/update-gtk4-dark-css" local gtk_css="$USER_HOME/.config/gtk-4.0/gtk.css" local css_dir="$USER_HOME/.config/gtk-4.0/arc-dark" if [ "$MODE" != "dark" ]; then rm -f "$gtk_css" rm -rf "$css_dir" ok "GTK4 uses the light theme (no Arc-Dark user CSS)." return 0 fi [ -x "$script" ] || { warn "update-gtk4-dark-css is missing – GTK4 remains Arc-Darker."; return 0; } if "$script"; then ok "GTK4 applications use Arc-Dark (GTK3 remains Arc-Darker)." else warn "GTK4 Arc-Dark CSS could not be generated." fi } # Removes a marked block from a text file. Used to take back the Thunar # override when switching back to the dark design. strip_managed_block() { local file=$1 begin=$2 end=$3 [ -f "$file" ] || return 0 grep -qF "$begin" "$file" || return 0 awk -v b="$begin" -v e="$end" ' $0 == b { skip = 1; next } $0 == e { skip = 0; next } !skip { print } ' "$file" > "$file.tmp.$$" && mv "$file.tmp.$$" "$file" } # Arc ships a Thunar-specific rule that paints the shortcuts pane dark # in *every* variant, including the light one: # .thunar scrolledwindow.sidebar treeview.view { # background: rgba(53, 57, 69, 0.95); color: #BAC3CF; } # That is intentional in Arc (Nautilus/Nemo look the same), but it # breaks the light design. A user CSS block restores the light palette. # It is appended to an existing gtk.css so custom rules are preserved. install_thunar_light_css() { local dir="$USER_HOME/.config/gtk-3.0" local css="$dir/gtk.css" local begin='/* BEGIN desktop-setup thunar-light */' local end='/* END desktop-setup thunar-light */' if [ "$MODE" = light ]; then mkdir -p "$dir" strip_managed_block "$css" "$begin" "$end" cat >> "$css" <<'EOF' /* BEGIN desktop-setup thunar-light */ /* Arc paints Thunar's shortcuts pane dark even in the light theme. * These rules restore the light surface colour (#f4f9ff). */ .thunar scrolledwindow.sidebar treeview.view { background: #f4f9ff; color: #232629; } .thunar scrolledwindow.sidebar treeview.view:hover { background: #e7f2ff; } .thunar scrolledwindow.sidebar treeview.view:selected, .thunar scrolledwindow.sidebar treeview.view:active { background: #d0ebff; color: #1864ab; } .thunar scrolledwindow.sidebar separator.sidebar { background-color: #cfe0f3; } /* END desktop-setup thunar-light */ EOF ok "Thunar sidebar: light Arc override installed." else if [ -f "$css" ] && grep -qF "$begin" "$css"; then strip_managed_block "$css" "$begin" "$end" if ! grep -q '[^[:space:]]' "$css"; then rm -f "$css" fi ok "Thunar sidebar: light override removed (dark theme)." fi fi } # Runs a command inside a D-Bus session. dconf – the persistent store # behind GSettings – only writes to ~/.config/dconf/user via D-Bus. # Without a session bus the values stay in memory and are lost at logout. # Reads one variable from the environment of a process. The installer is # often started over SSH, where the shell has none of the session # variables; the process that owns the graphical session does. proc_env() { local pid=$1 var=$2 tr '\0' '\n' < "/proc/$pid/environ" 2>/dev/null \ | awk -v k="$var" 'index($0, k "=") == 1 { sub(/^[^=]*=/, ""); print; exit }' } # Prints " " of the process that owns the graphical session. session_process() { local cand pid for cand in labwc sway xfwm4 gnome-shell kwin_wayland plasmashell; do pid=$(pgrep -u "$(id -u)" -x "$cand" 2>/dev/null | head -n 1) if [ -n "$pid" ]; then printf '%s %s\n' "$cand" "$pid" return 0 fi done return 1 } # Adopts the environment of the real graphical session, but only for # variables the current shell does not already have. This makes # gsettings/dconf, the GTK self-test and reload_session act on the # session that is actually running – even when started via SSH. adopt_session_env() { local sp="" pid="" v="" val="" sp=$(session_process) || return 1 pid=${sp##* } for v in XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS WAYLAND_DISPLAY DISPLAY \ XDG_CURRENT_DESKTOP XDG_SESSION_TYPE; do [ -n "${!v:-}" ] && continue val=$(proc_env "$pid" "$v") [ -n "$val" ] && export "$v=$val" done # The compositor itself usually has no WAYLAND_DISPLAY; use its socket. if [ -z "${WAYLAND_DISPLAY:-}" ] && [ -z "${DISPLAY:-}" ]; then local rt=${XDG_RUNTIME_DIR:-/run/user/$(id -u)} sock for sock in "$rt"/wayland-*; do [ -S "$sock" ] || continue case "$sock" in *.lock) continue ;; esac export XDG_RUNTIME_DIR="$rt" export WAYLAND_DISPLAY=${sock##*/} break done fi return 0 } # Prints what the graphical session really uses. This is the decisive # information when the installer itself runs in an SSH shell: GTK and # Thunar read their settings from the session, not from that shell. diagnose_session() { local sp="" name="" pid="" v="" val="" found=0 info "Graphical session (what GTK/Thunar really use) …" if sp=$(session_process); then name=${sp% *}; pid=${sp##* } printf ' compositor = %s (pid %s)\n' "$name" "$pid" else info "No graphical session yet (fresh installation) – settings are stored for the next login." fi # Print the values the installer will actually use. They were adopted # from the session above when the shell itself had none (SSH). for v in XDG_CURRENT_DESKTOP XDG_SESSION_TYPE WAYLAND_DISPLAY DISPLAY \ XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS; do val=${!v:-} if [ -z "$val" ] && [ -n "$pid" ]; then val=$(proc_env "$pid" "$v") fi printf ' %-17s = %s\n' "$v" "${val:-(unset)}" done # XSETTINGS daemons (Xfce, GNOME, xsettingsd) override the icon theme # of GTK3 programs such as Thunar. for v in xfsettingsd xsettingsd gsd-xsettings gnome-settings-daemon; do if pgrep -x "$v" >/dev/null 2>&1; then warn "$v is running and may override the GTK icon theme (XSETTINGS)." found=1 fi done if [ "$found" -eq 0 ]; then ok "No competing XSETTINGS daemon found." fi return 0 } run_with_dbus() { # Prefer the bus of the running session, so that dconf-service and # the already running GTK programs see the new values immediately. if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]; then adopt_session_env >/dev/null 2>&1 || true fi if [ -n "${DBUS_SESSION_BUS_ADDRESS:-}" ]; then "$@" elif command -v dbus-run-session >/dev/null 2>&1; then dbus-run-session -- "$@" else "$@" fi } # Reads a GSettings value without quotes. gsettings_value() { run_with_dbus gsettings get "$1" "$2" 2>/dev/null \ | sed -e "s/^'//" -e "s/'$//" } # Installs the dconf settings captured from the reference system where # the Qogir icons work. This is the authoritative state: it guarantees # the icon theme even if writing through GSettings does not persist. install_dconf_theme_db() { local src_db="$SCRIPT_DIR/assets/dconf-$MODE-user" local src_conf="$SCRIPT_DIR/assets/dconf-$MODE.conf" local dir="$USER_HOME/.config/dconf" local dst="$dir/user" # Target the bus of the running session, otherwise dconf-service of # the session keeps its old in-memory state and can overwrite the file. adopt_session_env >/dev/null 2>&1 || true [ -f "$src_db" ] || { warn "Bundled dconf database is missing: $src_db"; return 1; } mkdir -p "$dir" chmod 700 "$dir" 2>/dev/null || true if [ -e "$dst" ]; then local backup="$USER_HOME/Backups/desktop-setup-dconf-$(date +%Y%m%d-%H%M%S)" mkdir -p "$backup" cp -a "$dst" "$backup/user" 2>/dev/null || true info "Backed up existing dconf database to $backup/user" fi # Preferred: load the readable reference dump through the dconf # service. The service then owns the state and persists it itself, # so a later flush cannot undo our values. if [ -f "$src_conf" ] && command -v dconf >/dev/null 2>&1; then if run_with_dbus dconf load / < "$src_conf"; then ok "Loaded the reference dconf settings ($MODE)." return 0 fi warn "dconf load failed – installing the database file instead." fi # Fallback: install the binary database captured from the reference # system. Stop the running service first so it cannot write its old # in-memory database over the file. if command -v systemctl >/dev/null 2>&1; then systemctl --user stop dconf.service >/dev/null 2>&1 || true fi # systemctl may return before the process has really exited. Wait for # it, otherwise the dying service overwrites the file again. local i for i in 1 2 3 4 5 6 7 8 9 10; do pgrep -x dconf-service >/dev/null 2>&1 || break sleep 0.2 done if pgrep -x dconf-service >/dev/null 2>&1; then pkill -x dconf-service >/dev/null 2>&1 || true sleep 0.3 fi install -m 600 "$src_db" "$dst" ok "Installed the reference dconf database ($MODE)." if command -v systemctl >/dev/null 2>&1; then systemctl --user start dconf.service >/dev/null 2>&1 || true fi return 0 } # Qogir ships SVG icons only. GTK3 renders them through the gdk-pixbuf # SVG loader from librsvg2-common. That package is only a Recommends of # libgtk-3-0t64, so `apt-get --no-install-recommends` (used by this # installer) leaves it out – Thunar then shows generic icons even though # the theme name and the icon files are perfectly correct. svg_loader_ok() { local f="" found=0 # Fast path that also works without python3-gi: the loader library # must be installed. for f in /usr/lib/*/gdk-pixbuf-2.0/*/loaders/libpixbufloader[_-]svg.so \ /usr/lib/gdk-pixbuf-2.0/*/loaders/libpixbufloader[_-]svg.so; do if [ -e "$f" ]; then found=1 break fi done [ "$found" -eq 1 ] || return 1 f="" for f in "$USER_HOME/.local/share/icons/Qogir-Manjaro-Dark/48/places/folder.svg" \ "$USER_HOME/.local/share/icons/Qogir-Manjaro/48/places/folder.svg"; do [ -f "$f" ] && break done [ -f "$f" ] || return 0 # nothing to test yet command -v python3 >/dev/null 2>&1 || return 0 python3 -c 'import gi; gi.require_version("GdkPixbuf", "2.0")' >/dev/null 2>&1 \ || return 0 python3 - "$f" <<'PY' >/dev/null 2>&1 import sys import gi gi.require_version("GdkPixbuf", "2.0") from gi.repository import GdkPixbuf try: GdkPixbuf.Pixbuf.new_from_file(sys.argv[1]) except Exception: raise SystemExit(1) PY } ensure_svg_loader() { if svg_loader_ok; then return 0 fi warn "SVG icons cannot be rendered: the gdk-pixbuf SVG loader is missing." warn "Qogir uses SVG only – Thunar would show generic icons." if ! command -v apt-get >/dev/null 2>&1; then warn "Install 'librsvg2-common' manually and restart Thunar." return 1 fi info "Installing librsvg2-common (SVG support for GTK/Thunar) …" if sudo env DEBIAN_FRONTEND=noninteractive \ apt-get install -y librsvg2-common; then ok "librsvg2-common installed." else warn "Installation failed. Run: sudo apt install librsvg2-common" return 1 fi if svg_loader_ok; then ok "SVG icons can be rendered now." else warn "SVG loader still not usable – a logout/login may be required." fi return 0 } # Verifies with GTK3 itself that the installed theme really resolves # icons. Only runs when a display is reachable; it never aborts the # installation. verify_icon_theme() { local theme=$1 command -v python3 >/dev/null 2>&1 || return 0 python3 -c 'import gi; gi.require_version("Gtk", "3.0")' >/dev/null 2>&1 \ || return 0 # When started over SSH, the shell has no display and no session bus. # Adopt them from the process that owns the graphical session, so the # test reflects what Thunar really sees. adopt_session_env >/dev/null 2>&1 || true if [ -z "${WAYLAND_DISPLAY:-}" ] && [ -z "${DISPLAY:-}" ]; then info "GTK3 icon self-test skipped (no graphical display reachable)." return 0 fi export GDK_BACKEND=${GDK_BACKEND:-wayland,x11} info "GTK3 icon self-test ($theme) …" local out out=$(python3 - "$theme" <<'PY' || true import sys import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk theme = sys.argv[1] settings = Gtk.Settings.get_default() if settings is None: print(" GTK could not open a display.") raise SystemExit(0) print(" gtk-icon-theme-name = %s" % settings.get_property("gtk-icon-theme-name")) icons = Gtk.IconTheme.get_default() print(" search path = %s" % icons.get_search_path()) for name in ("folder", "org.xfce.thunar", "pan-down-symbolic"): info = icons.lookup_icon(name, 48, 0) if info is None: print(" %-20s-> NOT FOUND" % name) continue try: pix = info.load_icon() print(" %-20s-> %s (%dx%d)" % (name, info.get_filename(), pix.get_width(), pix.get_height())) except Exception as exc: print(" %-20s-> %s (LOAD FAILED: %s)" % (name, info.get_filename(), exc)) PY ) printf '%s\n' "$out" # Turn the self-test into an explicit warning – the log is the only # diagnostic available when the installer runs over SSH. if printf '%s\n' "$out" | grep -q 'gtk-icon-theme-name = Adwaita'; then warn "GTK in the running session resolves 'Adwaita' instead of '$theme'." warn "The theme value is stored, but the session does not use it (logout/login or wrong session)." elif printf '%s\n' "$out" | grep -q 'LOAD FAILED'; then warn "GTK cannot render the icons of '$theme' (missing SVG loader)." warn "Install librsvg2-common, then restart Thunar." elif printf '%s\n' "$out" | grep -q 'NOT FOUND'; then warn "GTK cannot resolve at least one icon of '$theme' in the running session." elif printf '%s\n' "$out" | grep -q 'gtk-icon-theme-name =' \ && ! printf '%s\n' "$out" | grep -q "folder .*-> .*/$theme/"; then # GTK silently falls back to hicolor/built-in icons when it cannot # load the SVG files – the theme name still looks correct. warn "GTK resolves the 'folder' icon from outside '$theme'." warn "The theme is set, but its icons are not usable (missing SVG loader or incomplete tree)." warn "Fix: sudo apt install librsvg2-common" fi } apply_gtk() { local script="$USER_HOME/.local/bin/set-gtk-settings" [ -x "$script" ] || { warn "set-gtk-settings is missing – GTK values not set."; return 0; } local expected=Qogir-Manjaro-Dark [ "$MODE" = dark ] || expected=Qogir-Manjaro info "Setting GTK, icon, cursor and font values ($MODE) …" adopt_session_env >/dev/null 2>&1 || true diagnose_session local sess_desktop=${XDG_CURRENT_DESKTOP:-} sp if [ -z "$sess_desktop" ]; then sp=$(session_process || true) sess_desktop=${sp%% *} fi case "$sess_desktop" in ""|labwc|sway|*labwc*|*Labwc*|*sway*|*Sway*) ;; *) warn "The graphical session is '$sess_desktop', not labwc/sway. Xfce/GNOME settings may override the icon theme." ;; esac # dconf is the persistent store behind GSettings. Without the # backend the values stay in memory – GTK/Thunar fall back to # Adwaita after the next login. if ! dpkg -s dconf-gsettings-backend >/dev/null 2>&1 \ || ! dpkg -s dconf-service >/dev/null 2>&1; then if command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then info "Installing dconf (persistent GSettings store) …" sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \ dconf-gsettings-backend dconf-service >/dev/null 2>&1 \ || warn "dconf could not be installed." else warn "dconf-gsettings-backend is missing – GSettings will not persist." fi fi # Write through GSettings first (updates a running session and keeps # unrelated keys). This can fail silently when the installer has no # usable D-Bus session, so it is not relied upon. if ! run_with_dbus "$script" "$MODE"; then warn "GSettings could not be set completely." fi # Install the reference database from the working system verbatim. # This is what actually guarantees Qogir in Thunar and all GTK apps. install_dconf_theme_db || true # Verify the final state. local got got=$(gsettings_value org.gnome.desktop.interface icon-theme) if [ "$got" = "$expected" ]; then ok "GSettings: icon-theme = $got (persisted)." else warn "GSettings: icon-theme is '${got:-unknown}' instead of '$expected'." warn "The reference database is installed; the value will be read at the next login." fi # Light mode uses the normal Arc theme; dark mode uses Arc-Darker # for GTK3 (dark headerbars) plus Arc-Dark for GTK4 via user CSS. local expected_gtk=Arc-Darker [ "$MODE" = dark ] || expected_gtk=Arc got=$(gsettings_value org.gnome.desktop.interface gtk-theme) if [ "$got" = "$expected_gtk" ]; then ok "GSettings: gtk-theme = $got (persisted)." else warn "GSettings: gtk-theme is '${got:-unknown}' instead of '$expected_gtk'." warn "The reference database is installed; the value will be read at the next login." fi # Qogir icons are SVG; without librsvg2-common Thunar renders only # generic placeholders. Install it before the self-test. ensure_svg_loader || true verify_icon_theme "$expected" install_gtk4_dark_css install_thunar_light_css } # ---------------------------------------------------------------- Greetd write_greeter_config() { local theme_file="$USER_HOME/.config/tuigreet/theme.conf" local theme tmp conf=/etc/greetd/config.toml [ -r "$theme_file" ] || { warn "Missing: $theme_file"; return 1; } theme=$(tr -d '\n' < "$theme_file") if [ -z "$theme" ] || printf '%s' "$theme" | LC_ALL=C grep -q '[^A-Za-z0-9=;.#_-]'; then warn "Invalid tuigreet theme in $theme_file" return 1 fi tmp=$(mktemp) cat > "$tmp" < "$tmp" <<'EOF' // Allow the greeter user _greetd to shut down or reboot the system. // The greeter does not run in an active logind session, so the default // rule (allow_active=yes) does not apply. polkit.addRule(function(action, subject) { if (subject.user != "_greetd") return; if (action.id == "org.freedesktop.login1.power-off" || action.id == "org.freedesktop.login1.power-off-multiple-sessions" || action.id == "org.freedesktop.login1.reboot" || action.id == "org.freedesktop.login1.reboot-multiple-sessions") { return polkit.Result.YES; } }); EOF if [ -f "$rule" ]; then sudo cp -a "$rule" "$rule.bak.$(date +%Y%m%d-%H%M%S)" fi sudo install -Dm644 "$tmp" "$rule" rm -f "$tmp" ok "polkit rule for greeter power written: $rule" } apply_greeter() { command -v tuigreet >/dev/null 2>&1 \ || { warn "tuigreet is missing – skipping the greeter."; return 0; } local dm other="" for dm in lightdm gdm3 sddm ly; do if systemctl is-enabled "$dm" >/dev/null 2>&1; then other=$dm; break; fi done write_greeter_config || return 0 write_greeter_polkit if [ -n "$other" ]; then warn "Display manager '$other' is enabled." if ask_yes_no "Enable greetd instead and disable '$other'?" n; then sudo systemctl disable --now "$other" >/dev/null 2>&1 \ || warn "Could not disable '$other'." sudo systemctl enable greetd >/dev/null 2>&1 \ && ok "greetd is enabled (reboot required)." \ || warn "greetd could not be enabled." else warn "greetd will not be enabled – '$other' remains the login screen." fi else sudo systemctl enable greetd >/dev/null 2>&1 \ && ok "greetd is enabled (reboot required)." \ || warn "greetd could not be enabled." fi } # ---------------------------------------------------------------- Keyring install_keyring_packages() { info "Installing keyring packages …" sudo apt-get update >/dev/null 2>&1 || warn "apt package lists could not be updated." if sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libpam-gnome-keyring libsecret-tools; then ok "libpam-gnome-keyring and libsecret-tools installed." else warn "Keyring packages could not be installed." fi } setup_keyring() { info "Setting up gnome-keyring as the secret service …" # PAM module: installed via APT_PACKAGES (libpam-gnome-keyring). local module module=$(dpkg -L libpam-gnome-keyring 2>/dev/null \ | grep '/pam_gnome_keyring\.so$' | head -n 1 || true) if [ -n "$module" ] && [ -e "$module" ]; then ok "PAM module pam_gnome_keyring present." else warn "pam_gnome_keyring.so is missing – the keyring will not be unlocked automatically at login." fi # greetd PAM: unlock the keyring with the password at login. local pam=/etc/pam.d/greetd if [ -f "$pam" ]; then local tmp changed=0 tmp=$(mktemp) cp "$pam" "$tmp" if ! grep -qE '^[[:space:]]*-?auth[[:space:]]+optional[[:space:]]+pam_gnome_keyring\.so' "$tmp"; then printf '\n# desktop-setup: unlock keyring at login\n-auth optional pam_gnome_keyring.so\n' >>"$tmp" changed=1 fi if ! grep -qE '^[[:space:]]*-?session[[:space:]]+optional[[:space:]]+pam_gnome_keyring\.so' "$tmp"; then printf -- '-session optional pam_gnome_keyring.so auto_start\n' >>"$tmp" changed=1 fi if [ "$changed" -eq 1 ]; then sudo cp -a "$pam" "$pam.desktop-setup.bak.$(date +%Y%m%d-%H%M%S)" sudo install -m 644 "$tmp" "$pam" ok "PAM for greetd extended (keyring is unlocked at login)." else ok "PAM for greetd already configured." fi rm -f "$tmp" else warn "$pam is missing – skipping keyring PAM." fi # Portal configuration: selects gnome-keyring as the secret backend. local portal="$USER_HOME/.config/xdg-desktop-portal/labwc-portals.conf" if [ -f "$portal" ]; then ok "Portal configuration present." elif [ -f "$SCRIPT_DIR/home/.config/xdg-desktop-portal/labwc-portals.conf" ]; then install -Dm644 "$SCRIPT_DIR/home/.config/xdg-desktop-portal/labwc-portals.conf" "$portal" ok "Portal configuration created: $portal" else warn "Portal configuration is missing – Flatpak apps may not find the secret service." fi # Restart the running portal so that the configuration takes effect. if systemctl --user is-active --quiet xdg-desktop-portal.service 2>/dev/null; then systemctl --user restart xdg-desktop-portal.service >/dev/null 2>&1 \ && ok "xdg-desktop-portal restarted." \ || warn "xdg-desktop-portal could not be restarted." fi ok "Keyring configured – the keyring is unlocked after the next login." } # ---------------------------------------------------------------- Flatpak install_flatpak_apps() { command -v flatpak >/dev/null 2>&1 \ || { warn "flatpak is missing – skipping Flatpak apps."; return 0; } info "Setting up Flathub …" sudo flatpak remote-add --if-not-exists flathub \ https://flathub.org/repo/flathub.flatpakrepo \ || warn "Flathub could not be added." local id for id in org.mozilla.firefox org.gnome.Evince com.github.tchx84.Flatseal; do if flatpak info "$id" >/dev/null 2>&1; then ok "$id is already installed." else info "Installing $id …" if sudo flatpak install -y flathub "$id"; then ok "$id installed." else warn "$id could not be installed." fi fi done # Firefox: GTK window buttons as a fallback in case the portal does # not pass the global GSettings value into the Flatpak sandbox. local app_cfg="$USER_HOME/.var/app/org.mozilla.firefox/config" mkdir -p "$app_cfg/gtk-3.0" "$app_cfg/gtk-4.0" printf '[Settings]\ngtk-decoration-layout=:minimize,maximize,close\n' \ > "$app_cfg/gtk-3.0/settings.ini" printf '[Settings]\ngtk-decoration-layout=:minimize,maximize,close\n' \ > "$app_cfg/gtk-4.0/settings.ini" # Short commands in the terminal: firefox, evince, flatseal. mkdir -p "$USER_HOME/.local/bin" local pair name app_id for pair in "firefox:org.mozilla.firefox" \ "evince:org.gnome.Evince" \ "flatseal:com.github.tchx84.Flatseal"; do name=${pair%%:*} app_id=${pair#*:} if [ -x "/var/lib/flatpak/exports/bin/$app_id" ]; then ln -sfn "/var/lib/flatpak/exports/bin/$app_id" \ "$USER_HOME/.local/bin/$name" fi done ok "Flatpak apps set up (Firefox, Evince, Flatseal)." } setup_flatpak_overrides() { command -v flatpak >/dev/null 2>&1 || return 0 info "Setting Flatpak overrides …" # Signal: default is SIGNAL_PASSWORD_STORE=basic (file). With # gnome-libsecret, Signal uses the keyring (org.freedesktop.secrets). # The Flatpak already allows access via its metadata. if flatpak info org.signal.Signal >/dev/null 2>&1; then if flatpak override --user \ --env=SIGNAL_PASSWORD_STORE=gnome-libsecret \ org.signal.Signal >/dev/null 2>&1; then ok "Signal uses gnome-keyring (SIGNAL_PASSWORD_STORE=gnome-libsecret)." else warn "Signal override could not be set." fi fi } # ---------------------------------------------------------------- Services apply_services() { info "Enabling services …" sudo systemctl enable --now NetworkManager >/dev/null 2>&1 \ && ok "NetworkManager enabled." \ || warn "NetworkManager could not be enabled." local s for s in pipewire pipewire-pulse wireplumber; do systemctl --user enable --now "$s" >/dev/null 2>&1 || \ warn "User service '$s' could not be enabled." done systemctl --user daemon-reload >/dev/null 2>&1 || true xdg-user-dirs-update >/dev/null 2>&1 || true ok "Services processed." } # ---------------------------------------------------------------- Node.js (nvm) install_node() { [ "$DO_NODE" -eq 1 ] || return 0 local nvm_dir="$USER_HOME/.nvm" installed export NVM_DIR="$nvm_dir" info "Installing Node.js via nvm …" if [ ! -s "$nvm_dir/nvm.sh" ]; then command -v curl >/dev/null 2>&1 \ || { warn "curl is missing – nvm cannot be downloaded."; return 0; } local tmp tmp=$(mktemp) if ! curl -fsSL \ "https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh" \ -o "$tmp"; then rm -f "$tmp" warn "nvm installation script could not be downloaded." return 0 fi if ! bash "$tmp"; then rm -f "$tmp" warn "nvm installation failed." return 0 fi rm -f "$tmp" ok "nvm $NVM_VERSION installed: $nvm_dir" else ok "nvm already present: $nvm_dir" fi # shellcheck disable=SC1090 . "$nvm_dir/nvm.sh" installed=$(nvm ls --no-colors 2>/dev/null \ | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1 || true) if [ -z "$installed" ]; then info "Installing Node.js LTS …" if ! nvm install --lts; then warn "Node.js LTS could not be installed." return 0 fi installed=$(nvm version 2>/dev/null || true) else ok "Node.js already present: $installed" fi # Do not override an existing nvm installation: only create the # default alias if none exists yet. fish resolves it dynamically. if [ ! -f "$nvm_dir/alias/default" ] && [ -n "$installed" ]; then nvm alias default "${installed#v}" >/dev/null 2>&1 || true fi nvm use default >/dev/null 2>&1 \ || nvm use "$installed" >/dev/null 2>&1 \ || true ok "Node.js: $(node --version 2>/dev/null || echo unknown) / npm $(npm --version 2>/dev/null || echo unknown)" } # ---------------------------------------------------------------- opencode install_opencode() { [ "$DO_OPENCODE" -eq 1 ] || return 0 local bin="$USER_HOME/.opencode/bin/opencode" if [ -x "$bin" ]; then ok "opencode already present: $("$bin" --version 2>/dev/null || echo "$bin")" return 0 fi command -v curl >/dev/null 2>&1 \ || { warn "curl is missing – opencode cannot be downloaded."; return 0; } info "Installing opencode …" local tmp tmp=$(mktemp) if ! curl -fsSL https://opencode.ai/install -o "$tmp"; then rm -f "$tmp" warn "opencode installation script could not be downloaded." return 0 fi # --no-modify-path: ~/.config/fish/config.fish already adds # ~/.opencode/bin to PATH (the dotfiles are installed by this script). if ! bash "$tmp" --no-modify-path; then rm -f "$tmp" warn "opencode installation failed." return 0 fi rm -f "$tmp" if [ -x "$bin" ]; then ok "opencode installed: $("$bin" --version 2>/dev/null || echo "$bin")" else warn "opencode binary was not found after installation." fi } # ---------------------------------------------------------------- uv install_uv() { [ "$DO_UV" -eq 1 ] || return 0 local bin="$USER_HOME/.local/bin/uv" if [ -x "$bin" ]; then ok "uv already present: $("$bin" --version 2>/dev/null || echo "$bin")" return 0 fi command -v curl >/dev/null 2>&1 \ || { warn "curl is missing – uv cannot be downloaded."; return 0; } info "Installing uv (Python package manager) …" local tmp tmp=$(mktemp) if ! curl -LsSf https://astral.sh/uv/install.sh -o "$tmp"; then rm -f "$tmp" warn "uv installation script could not be downloaded." return 0 fi # ~/.local/bin is already in PATH via the fish config. if ! env UV_NO_MODIFY_PATH=1 sh "$tmp"; then rm -f "$tmp" warn "uv installation failed." return 0 fi rm -f "$tmp" if [ -x "$bin" ]; then ok "uv installed: $("$bin" --version 2>/dev/null || echo "$bin")" else warn "uv binary was not found after installation." fi } # ---------------------------------------------------------------- Cargo / Rust install_cargo() { [ "$DO_CARGO" -eq 1 ] || return 0 local bin="${CARGO_HOME:-$USER_HOME/.cargo}/bin/cargo" if [ -x "$bin" ]; then ok "Cargo already present: $("$bin" --version 2>/dev/null || echo "$bin")" return 0 fi command -v curl >/dev/null 2>&1 \ || { warn "curl is missing – Rust cannot be downloaded."; return 0; } info "Installing Rust (rustup, cargo) …" local tmp tmp=$(mktemp) if ! curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs -o "$tmp"; then rm -f "$tmp" warn "rustup installation script could not be downloaded." return 0 fi # rustup writes ~/.config/fish/conf.d/rustup.fish, so cargo is in # PATH in the desktop session after the next login. if ! sh "$tmp" -y; then rm -f "$tmp" warn "Rust installation failed." return 0 fi rm -f "$tmp" if [ -x "$bin" ]; then ok "Cargo installed: $("$bin" --version 2>/dev/null || echo "$bin")" else warn "cargo binary was not found after installation." fi if ! command -v cc >/dev/null 2>&1; then warn "C compiler 'cc' is missing – crates with native code cannot link." warn "Fix: sudo apt install build-essential" fi } # ---------------------------------------------------------------- Docker install_docker() { [ "$DO_DOCKER" -eq 1 ] || return 0 # docker.io, docker-cli and docker-compose are installed by # install_packages() (conditional apt list). if ! command -v docker >/dev/null 2>&1; then warn "docker is missing – the package installation seems to have failed." return 0 fi info "Enabling Docker …" if sudo systemctl enable --now docker >/dev/null 2>&1; then ok "Docker service enabled." else warn "Docker service could not be enabled." fi # Running docker without sudo requires membership in the docker group. if id -nG "$USER_NAME" 2>/dev/null | tr ' ' '\n' | grep -qx docker; then ok "$USER_NAME is already in the docker group." elif sudo usermod -aG docker "$USER_NAME"; then ok "$USER_NAME added to the docker group (active after the next login)." else warn "Could not add $USER_NAME to the docker group." fi local compose compose=$(docker compose version --short 2>/dev/null \ || docker-compose --version 2>/dev/null || true) ok "Docker: $(docker --version 2>/dev/null || echo unknown)${compose:+ / Compose: $compose}" } # ---------------------------------------------------------------- Ollama install_ollama() { [ "$DO_OLLAMA" -eq 1 ] || return 0 if command -v ollama >/dev/null 2>&1; then ok "Ollama already present: $(ollama --version 2>/dev/null | head -n 1)" return 0 fi command -v curl >/dev/null 2>&1 \ || { warn "curl is missing – Ollama cannot be downloaded."; return 0; } command -v zstd >/dev/null 2>&1 \ || { warn "zstd is missing – Ollama cannot be unpacked."; return 0; } info "Installing Ollama (local LLMs) …" local tmp tmp=$(mktemp) if ! curl -fsSL https://ollama.com/install.sh -o "$tmp"; then rm -f "$tmp" warn "Ollama installation script could not be downloaded." return 0 fi # The script installs the binary to /usr/local/bin, creates the # ollama user and enables the systemd service – therefore root. if ! sudo sh "$tmp"; then rm -f "$tmp" warn "Ollama installation failed." return 0 fi rm -f "$tmp" if command -v ollama >/dev/null 2>&1; then ok "Ollama installed: $(ollama --version 2>/dev/null | head -n 1)" else warn "ollama binary was not found after installation." fi } # ---------------------------------------------------------------- fish set_fish_shell() { [ "$SET_FISH_SHELL" -eq 1 ] || return 0 local fish_bin=/usr/bin/fish if ! command -v fish >/dev/null 2>&1; then warn "fish is not installed – login shell remains unchanged." return 0 fi if ! grep -qx "$fish_bin" /etc/shells 2>/dev/null; then warn "fish is not listed in /etc/shells – login shell remains unchanged." return 0 fi local current current=$(getent passwd "$USER_NAME" | cut -d: -f7) if [ "$current" = "$fish_bin" ]; then ok "fish is already the login shell." return 0 fi info "Setting fish as the login shell for $USER_NAME …" if chsh -s "$fish_bin"; then ok "fish is now the login shell." else warn "chsh failed – fish remains only the terminal shell." fi } # ---------------------------------------------------------------- Reload reload_session() { # Also works when the installer was started over SSH. adopt_session_env >/dev/null 2>&1 || true [ -n "${WAYLAND_DISPLAY:-}" ] || return 0 info "Reloading the running session (wallpaper, Waybar, mako, Thunar, labwc) …" local wp="$USER_HOME/.local/share/backgrounds/labwc-$MODE.png" if command -v swaybg >/dev/null 2>&1; then pkill -x swaybg >/dev/null 2>&1 || true setsid swaybg -i "$wp" -m fill >/dev/null 2>&1 & fi if command -v waybar >/dev/null 2>&1; then pkill -x waybar >/dev/null 2>&1 || true setsid waybar >/dev/null 2>&1 & fi if command -v mako >/dev/null 2>&1; then pkill -x mako >/dev/null 2>&1 || true setsid mako >/dev/null 2>&1 & fi # Thunar caches the icon theme when it starts; without a restart the # old icons remain visible. if command -v thunar >/dev/null 2>&1 && pgrep -x thunar >/dev/null 2>&1; then pkill -x thunar >/dev/null 2>&1 || true setsid thunar --daemon >/dev/null 2>&1 & fi if command -v labwc >/dev/null 2>&1; then labwc -r >/dev/null 2>&1 || true fi } # ---------------------------------------------------------------- Checks final_checks() { local full=${1:-1} info "Checking core components …" if [ "$full" -eq 1 ]; then local cmd for cmd in labwc waybar kitty foot fuzzel fish thunar swaylock \ gparted loupe python3; do if command -v "$cmd" >/dev/null 2>&1; then ok "$cmd" else warn "$cmd is missing" fi done if command -v flatpak >/dev/null 2>&1; then local id for id in org.mozilla.firefox org.gnome.Evince com.github.tchx84.Flatseal; do if flatpak info "$id" >/dev/null 2>&1; then ok "Flatpak: $id" else warn "Flatpak missing: $id" fi done else warn "flatpak is missing" fi if [ "$DO_RUSTICL" -eq 1 ]; then if [ -f "$USER_HOME/.config/OpenCL/vendors/rusticl.icd" ]; then ok "Rusticl ICD configured" else warn "Rusticl ICD is missing" fi fi if [ "$DO_VM_RENDERER" -eq 1 ]; then if grep -qE '^[[:space:]]*WLR_RENDERER=pixman' \ "$USER_HOME/.config/labwc/environment" 2>/dev/null; then ok "pixman renderer set for the VM" else warn "pixman renderer is missing in ~/.config/labwc/environment" fi fi if [ "$SET_FISH_SHELL" -eq 1 ]; then if [ "$(getent passwd "$USER_NAME" | cut -d: -f7)" = /usr/bin/fish ]; then ok "fish is the login shell" else warn "fish is not the login shell (chsh -s /usr/bin/fish)" fi fi if [ -x /usr/libexec/xfce-polkit ] || command -v xfce-polkit >/dev/null 2>&1; then ok "xfce-polkit (PolicyKit agent)" elif command -v lxpolkit >/dev/null 2>&1; then ok "lxpolkit (PolicyKit agent)" else warn "No PolicyKit agent – pkexec/gparted cannot ask for the password" fi if grep -q 'desktop-setup: wayland root' /usr/sbin/gparted 2>/dev/null; then ok "gparted uses the desktop user's display under Wayland" else warn "gparted Wayland patch is missing – 'gparted' as root may show no window" fi if [ -f /etc/polkit-1/rules.d/49-greetd-power.rules ]; then ok "polkit rule for greeter power" else warn "polkit rule for greeter power is missing" fi if dpkg -L libpam-gnome-keyring 2>/dev/null \ | grep -q '/pam_gnome_keyring\.so$'; then ok "PAM module pam_gnome_keyring" else warn "libpam-gnome-keyring is missing – the keyring is not unlocked at login" fi if grep -qE '^[[:space:]]*-?session[[:space:]]+optional[[:space:]]+pam_gnome_keyring\.so' \ /etc/pam.d/greetd 2>/dev/null; then ok "greetd PAM unlocks the keyring at login" else warn "pam_gnome_keyring is missing in /etc/pam.d/greetd" fi if grep -q 'org.freedesktop.impl.portal.Secret=gnome-keyring' \ "$USER_HOME/.config/xdg-desktop-portal/labwc-portals.conf" 2>/dev/null; then ok "Secret portal uses gnome-keyring" else warn "Secret portal configuration is missing – Flatpak apps may not find the keyring" fi if command -v flatpak >/dev/null 2>&1 \ && flatpak info org.signal.Signal >/dev/null 2>&1; then if flatpak override --user --show org.signal.Signal 2>/dev/null \ | grep -q '^SIGNAL_PASSWORD_STORE=gnome-libsecret$'; then ok "Signal uses gnome-keyring (SIGNAL_PASSWORD_STORE)" else warn "Signal keyring override is missing – Signal otherwise stores the password in a file" fi fi if systemctl is-enabled greetd >/dev/null 2>&1; then ok "greetd is enabled" else warn "greetd is not enabled" fi fi # Node.js local node_bin if command -v node >/dev/null 2>&1; then ok "node $(node --version 2>/dev/null) ($(command -v node))" elif [ -d "$USER_HOME/.nvm/versions/node" ]; then node_bin=$(find "$USER_HOME/.nvm/versions/node" -maxdepth 3 \ -type f -name node -perm -u+x 2>/dev/null \ | sort -V | tail -n 1 || true) if [ -n "$node_bin" ]; then ok "node $("$node_bin" --version 2>/dev/null) (nvm, in PATH after login)" elif [ "$DO_NODE" -eq 1 ]; then warn "Node.js was selected but cannot be found" else info "Node.js not installed." fi else if [ "$DO_NODE" -eq 1 ]; then warn "Node.js was selected but is not installed" else info "Node.js not installed." fi fi # Optional developer tools local tool tool_bin tool_want for tool in opencode uv cargo ollama; do case "$tool" in opencode) tool_bin="$USER_HOME/.opencode/bin/opencode"; tool_want=$DO_OPENCODE ;; uv) tool_bin="$USER_HOME/.local/bin/uv"; tool_want=$DO_UV ;; cargo) tool_bin="${CARGO_HOME:-$USER_HOME/.cargo}/bin/cargo"; tool_want=$DO_CARGO ;; ollama) tool_bin=$(command -v ollama 2>/dev/null || true); tool_want=$DO_OLLAMA ;; esac if [ -n "$tool_bin" ] && [ -x "$tool_bin" ]; then ok "$tool $("$tool_bin" --version 2>/dev/null | head -n 1) ($tool_bin)" elif [ "$tool_want" -eq 1 ]; then warn "$tool was selected but cannot be found" else info "$tool not installed." fi done # Cargo needs cc to link; report it whenever cargo is present. if [ "$DO_CARGO" -eq 1 ] \ || [ -x "${CARGO_HOME:-$USER_HOME/.cargo}/bin/cargo" ] \ || command -v cargo >/dev/null 2>&1; then if command -v cc >/dev/null 2>&1; then ok "C toolchain: $(cc --version 2>/dev/null | head -n 1)" else warn "C toolchain (cc) is missing – cargo cannot link native code" warn "Fix: sudo apt install build-essential" fi fi # Editors / music player from the apt list local app for app in mousepad hx kew; do if command -v "$app" >/dev/null 2>&1; then ok "$app installed" else warn "$app is missing" fi done if python3 -c 'import ensurepip' >/dev/null 2>&1; then ok "python3-venv present (venv can install pip)" else warn "python3-venv is missing – 'python3 -m venv' cannot install pip" fi if [ "$DO_DOCKER" -eq 1 ] || command -v docker >/dev/null 2>&1; then if command -v docker >/dev/null 2>&1; then ok "docker $(docker --version 2>/dev/null | head -n 1)" if docker compose version >/dev/null 2>&1; then ok "docker compose $(docker compose version --short 2>/dev/null)" elif command -v docker-compose >/dev/null 2>&1; then ok "docker-compose $(docker-compose --version 2>/dev/null | head -n 1)" else warn "docker-compose is missing" fi if id -nG "$USER_NAME" 2>/dev/null | tr ' ' '\n' | grep -qx docker; then ok "$USER_NAME is in the docker group" else warn "$USER_NAME is not in the docker group (docker needs sudo)" fi elif [ "$DO_DOCKER" -eq 1 ]; then warn "Docker was selected but docker is missing" fi fi if qogir_icons_complete; then ok "Qogir icons complete (light and dark)" else warn "Qogir icons are incomplete – Thunar may show Adwaita icons" fi local want_icons=Qogir-Manjaro have_icons if [ "$MODE" = dark ]; then want_icons=Qogir-Manjaro-Dark fi have_icons=$(gsettings_value org.gnome.desktop.interface icon-theme) if [ "$have_icons" = "$want_icons" ]; then ok "Icon theme: $want_icons" else warn "Icon theme is ${have_icons:-unknown} instead of '$want_icons'" fi if [ -s "$USER_HOME/.config/dconf/user" ]; then ok "dconf database present ($(stat -c%s "$USER_HOME/.config/dconf/user" 2>/dev/null) bytes)" else warn "dconf database is missing – the icon theme may be lost at logout" fi if [ -e "$USER_HOME/.local/share/icons/$want_icons/index.theme" ]; then ok "Icon directory: ~/.local/share/icons/$want_icons" else warn "Icon directory ~/.local/share/icons/$want_icons is missing" fi if svg_loader_ok; then ok "SVG icon loader present (Qogir icons can be rendered)" else warn "SVG icon loader missing – Thunar will show generic icons" warn "Fix: sudo apt install librsvg2-common" fi if [ -L "$USER_HOME/.icons" ] \ && [ "$(readlink -f "$USER_HOME/.icons")" = "$(readlink -f "$USER_HOME/.local/share/icons")" ]; then ok "~/.icons points to ~/.local/share/icons" elif [ -e "$USER_HOME/.icons/Qogir-Manjaro-Dark/cursors/default" ]; then ok "Qogir cursor theme linked (~/.icons)" else warn "Qogir cursor theme not linked in ~/.icons" fi local want_scheme=prefer-light have_scheme if [ "$MODE" = dark ]; then want_scheme=prefer-dark fi have_scheme=$(gsettings_value org.gnome.desktop.interface color-scheme) if [ "$have_scheme" = "$want_scheme" ]; then ok "GTK colour scheme: $want_scheme" else warn "GTK colour scheme is '${have_scheme:-unknown}' instead of '$want_scheme'" fi local want_gtk=Arc have_gtk if [ "$MODE" = dark ]; then want_gtk=Arc-Darker fi have_gtk=$(gsettings_value org.gnome.desktop.interface gtk-theme) if [ "$have_gtk" = "$want_gtk" ]; then ok "GTK theme: $want_gtk" else warn "GTK theme is '${have_gtk:-unknown}' instead of '$want_gtk'" fi local thunar_css="$USER_HOME/.config/gtk-3.0/gtk.css" if [ "$MODE" = light ]; then if grep -qF 'BEGIN desktop-setup thunar-light' "$thunar_css" 2>/dev/null; then ok "Thunar sidebar: light override active" else warn "Thunar sidebar override is missing – the pane stays dark (Arc default)" fi elif grep -qF 'BEGIN desktop-setup thunar-light' "$thunar_css" 2>/dev/null; then warn "Thunar light override is still active in the dark theme" fi if [ "$MODE" = dark ]; then if grep -q 'arc-dark/gtk-main-dark.css' \ "$USER_HOME/.config/gtk-4.0/gtk.css" 2>/dev/null \ && [ -f "$USER_HOME/.config/gtk-4.0/arc-dark/gtk-main-dark.css" ]; then ok "GTK4: Arc-Dark (GTK3 remains Arc-Darker)" else warn "GTK4 Arc-Dark CSS is missing – GTK4 apps remain Arc-Darker" fi fi if command -v gsettings >/dev/null 2>&1; then local layout layout=$(gsettings_value org.gnome.desktop.wm.preferences button-layout) case "$layout" in *minimize*maximize*close*) ok "Window buttons: minimize/maximize/close enabled ($layout)" ;; *) warn "Window buttons incomplete (button-layout=${layout:-unknown})" ;; esac fi if command -v swayidle >/dev/null 2>&1 \ && [ -x "$USER_HOME/.local/bin/idle-action" ]; then ok "Idle manager configured (lock 10 min, display off 15 min, suspend 30 min)" else warn "Idle manager incomplete – swayidle or idle-action is missing" fi if command -v wlopm >/dev/null 2>&1; then ok "wlopm installed (display off via wlr-output-power-management)" else warn "wlopm is missing – display off uses wlr-randr as fallback" fi if command -v wdisplays >/dev/null 2>&1; then ok "wdisplays installed (monitors/resolution)" else warn "wdisplays is missing – monitors can only be configured via wlr-randr" fi } # ---------------------------------------------------------------- Flows print_footer() { printf '\n%sDone.%s\n' "$G" "$N" [ -n "$MODE" ] && printf 'Theme: %s\n' "$MODE" [ -n "${BACKUP_DIR:-}" ] && printf 'Backup: %s\n' "$BACKUP_DIR" cat </dev/null; then had_vm_renderer=1 fi info "Theme: $MODE" if ! ask_yes_no "Apply the theme now?" y; then info "Cancelled – nothing was changed." return 0 fi # A theme-only run on a fresh system must also provide the icon tree, # otherwise GTK falls back to Adwaita even though GSettings is correct. if ! qogir_icons_complete; then install_icons fi apply_dotfiles ensure_cursor_theme_link # The greeter gets its theme from /etc/greetd/config.toml, which is # generated from ~/.config/tuigreet/theme.conf. Rewrite it here, # otherwise the login screen keeps the previous (e.g. dark) theme. if [ -f /etc/greetd/config.toml ] && command -v tuigreet >/dev/null 2>&1; then info "Updating the greetd login theme …" if command -v sudo >/dev/null 2>&1 && sudo -v; then write_greeter_config || warn "The greetd theme could not be updated." else warn "greetd theme not updated (sudo failed) – the login screen keeps its previous theme." fi fi # A previously configured pixman renderer (VM) is preserved. if [ "$had_vm_renderer" -eq 1 ]; then DO_VM_RENDERER=1 setup_vm_renderer fi # A previously configured Rusticl is preserved when changing the theme. if [ -f "$USER_HOME/.config/OpenCL/vendors/rusticl.icd" ]; then DO_RUSTICL=1 setup_rusticl fi apply_gtk reload_session final_checks 0 print_footer } gparted_only() { require_sudo install_gparted patch_gparted_wayland printf '\n%sDone.%s\n' "$G" "$N" } keyring_only() { require_sudo install_keyring_packages setup_keyring setup_flatpak_overrides printf '\n%sDone.%s\n' "$G" "$N" } main_menu() { local choice printf '\n%s╔══════════════════════════════════════════════╗%s\n' "$B" "$N" printf '%s║ labwc desktop – Installation ║%s\n' "$B" "$N" printf '%s╚══════════════════════════════════════════════╝%s\n\n' "$B" "$N" printf 'What would you like to do?\n\n' printf ' 1) Full installation (recommended)\n' printf ' 2) Change theme only (light/dark)\n' printf ' 3) Patch GParted for Wayland only\n' printf ' 4) Set up keyring (gnome-keyring) only\n' printf ' 5) Quit\n\n' while true; do read -r -p "Choice [1-5]: " choice || exit 0 case "${choice:-}" in 1) full_install; return 0 ;; 2) theme_only; return 0 ;; 3) gparted_only; return 0 ;; 4) keyring_only; return 0 ;; 5|q|Q|exit|quit) printf 'Cancelled.\n'; exit 0 ;; *) printf 'Please enter 1 to 5.\n' ;; esac done } # ---------------------------------------------------------------- Start if [ "$#" -gt 0 ]; then case "$1" in -h|--help) usage; exit 0 ;; *) die "This script is interactive and does not accept parameters. Please start it without arguments." ;; esac fi [ "$(id -u)" -ne 0 ] \ || die "Please start as a normal user – the script calls sudo itself." [ -t 0 ] \ || die "This script is interactive and requires a terminal. Please run it directly in a terminal." # If the graphical session belongs to a different user, the theme would be # installed into the wrong home directory and would never be visible. seat_user="" if command -v loginctl >/dev/null 2>&1; then seat_user=$(loginctl list-sessions --no-legend 2>/dev/null \ | awk '$4 == "seat0" { print $3; exit }') fi if [ -n "${seat_user:-}" ] && [ "$seat_user" != "$USER_NAME" ]; then warn "The graphical session belongs to '$seat_user', but this script is installing for '$USER_NAME'." warn "The theme would be written to $USER_HOME and would not affect '$seat_user'." if ! ask_yes_no "Continue anyway?" n; then exit 1 fi fi [ -d "$SCRIPT_DIR/themes/dark/home" ] \ || die "Theme 'dark' not found – is the bundle complete?" [ -d "$SCRIPT_DIR/themes/light/home" ] \ || die "Theme 'light' not found – is the bundle complete?" [ -d "$SCRIPT_DIR/home" ] \ || die "Base skeleton '$SCRIPT_DIR/home' is missing." main_menu